このサイト(https://www.sejuku.net/blog/39936#VirtualBox)を参考に
Ruby と Ruby on Rails の開発構築をしているのですが、Rails のインストール作業として、
$bundle install --path vendor/bundler
を実行したのですが、下記エラーが発生しました。
発生している問題・エラーメッセージ
[!] There was an error parsing `Gemfile`: You cannot specify the same gem twice with different version requirements. You specified: rails (~> 5.1.6) and rails (~> 5.1.4therubyracer). Bundler cannot continue.
おそらく、異なるバージョンを複数回指定することはできません的な事を言ってるんと思うんですが、どうすれば解消できるでしょうか。
上記サイトの手順通りにやっていたんですが、二点ほど違う手順を踏んでしまいました。
一つは「gem “rails” のコメントを外す」の意味が分からず、
sed -i 's/# gem "rails"/gem "rails", "~> 5.1.0"/g' Gemfile ```をそのままコピーして実行してしまった事。 (実は未だに確信がないのですが、#←を消すってことでしょうか?間違ってたらごめんなさい。正直自信ないです) もうひとつは、railsチュートリアルを学ぶための環境構築なので、railsチュートリアルでrailsのバージョンを5.1.4に指定するとあったので、後で二度手間になると思い、上記コードの5.1.0を5.1.4に書き換えて実行したことです。 よくわからないのは5.1.6です。このバージョンは書き込んだ覚えがないのです。 分かる方、教えて頂きたいです。 >dyoshikawaさん こういうことでよろしいのでしょうか?間違ってたらすみません! ```ここに言語を入力 [vagrant@localhost ~]$ gem environment RubyGems Environment: - RUBYGEMS VERSION: 2.6.14.1 - RUBY VERSION: 2.4.4 (2018-03-28 patchlevel 296) [x86_64-linux] - INSTALLATION DIRECTORY: /home/vagrant/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0 - USER INSTALLATION DIRECTORY: /home/vagrant/.gem/ruby/2.4.0 - RUBY EXECUTABLE: /home/vagrant/.rbenv/versions/2.4.4/bin/ruby - EXECUTABLE DIRECTORY: /home/vagrant/.rbenv/versions/2.4.4/bin - SPEC CACHE DIRECTORY: /home/vagrant/.gem/specs - SYSTEM CONFIGURATION DIRECTORY: /home/vagrant/.rbenv/versions/2.4.4/etc - RUBYGEMS PLATFORMS: - ruby - x86_64-linux - GEM PATHS: - /home/vagrant/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0 - /home/vagrant/.gem/ruby/2.4.0 - GEM CONFIGURATION: - :update_sources => true - :verbose => true - :backtrace => false - :bulk_threshold => 1000 - REMOTE SOURCES: - https://rubygems.org/ - SHELL PATH: - /home/vagrant/.rbenv/versions/2.4.4/bin - /home/vagrant/.rbenv/libexec - /home/vagrant/.rbenv/plugins/r/bin - /home/vagrant/.rbenv/shims - /home/vagrant/.rbenv/bin - /usr/local/bin - /usr/bin - /usr/local/sbin - /usr/sbin - /home/vagrant/.local/bin - /home/vagrant/bin
takahashimさん
[vagrant@localhost ~]$ mkdir -p app/samurai/sample1 [vagrant@localhost ~]$ cd app/samurai/sample1/ [vagrant@localhost sample1]$ bundle init Gemfile already exists at /home/vagrant/app/samurai/sample1/Gemfile [vagrant@localhost sample1]$ sed -i 's/ gem "rails"/gem "rails", "~> 5.1.0"/g' Gemfile [vagrant@localhost sample1]$ bundle install --path vendor/bundler [!] There was an error parsing `Gemfile`: You cannot specify the same gem twice with different version requirements. You specified: rails (~> 5.1.6) and rails (~> 5.1.4therubyracer). Bundler cannot continue. # from /home/vagrant/app/samurai/sample1/Gemfile:20 # ------------------------------------------- # # See https://github.com/rails/execjs#readme for more supported runtimes > gem "rails", "~> 5.1.4"'therubyracer', platforms: :ruby # # -------------------------------------------
>dyoshikawaさん
何から何まで無知で申し訳ないです。お手数かけます。
これのことでしょうか?
[vagrant@localhost sample1]$ cat Gemfile source 'https://rubygems.org' git_source(:github) do |repo_name| repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") "https://github.com/#{repo_name}.git" end # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.1.6' # Use sqlite3 as the database for Active Record gem 'sqlite3' # Use Puma as the app server gem 'puma', '~> 3.7' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # See https://github.com/rails/execjs#readme for more supported runtimes gem "rails", "~> 5.1.4"'therubyracer', platforms: :ruby # Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.2' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.5' # Use Redis adapter to run Action Cable in production gem "rails", "~> 5.1.4"'redis', '~> 4.0' # Use ActiveModel has_secure_password gem "rails", "~> 5.1.4"'bcrypt', '~> 3.1.7' # Use Capistrano for deployment gem "rails", "~> 5.1.4"'capistrano-rails', group: :development group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] # Adds support for Capybara system testing and selenium driver gem 'capybara', '~> 2.13' gem 'selenium-webdriver' end group :development do # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. gem 'web-console', '>= 3.3.0' gem 'listen', '>= 3.0.5', '< 3.2' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
お二方へ。
数日にわたって回答いただきありがとうございました。
お二方の御指示通り、色々試行錯誤してみましたが、何時間もエラーの連発でちょっと疲弊しきっています。
自分には環境構築はまだ早かったということで、クラウドIDEを使ってみようかと思います。
色々調べているうちに、エラーとはちゃんと向き合うべきだという声もたくさんありましたが、環境構築の段階で何日も何時間もかかっているため、このままではプログラミングの学習自体、挫折してしまいそうなので、今回は折れようかと思います。
ありがとうございました。
回答2件
あなたの回答
tips
プレビュー