我想在OpenAppAcademy開始學習Ruby On Rails,但是當我在18.04 Ubuntu的終端上運行rails console時,我得到
/var/lib/gems/2.5.0/gems/railties-6. 1.4.1/lib/rails/app_loader.rb:53: warning:不安全的世界可寫目錄/mnt/c 在PATH,模式040777。
回溯(最近一次呼叫)。
5: from bin/rails:3:in `<main>'
4: from bin/rails:3:in `load'
3: 從/mnt/c/Users/RedmiBook/Desktop/projects/APPACADEMY/SQL/Active Record/Intro To Rails/bin/spring:10:in `<top (required)> '
2: from /mnt/c/Users/RedmiBook/Desktop/projects/APPACADEMY/SQL/Active Record/Intro To Rails/bin/spring: 10:in `new'
1: from /usr/lib/ruby/vendor_ruby/bundler/lockfile_parser.rb:95:in `initialize'
/usr/lib/ruby/vendor_ruby/bundler/lockfile_parser.rb:108:in `warn_for_outdated_bundler_version': 你必須使用Bundler 2 or greater with this lockfile。(Bundler::LockfileError)
我的捆綁器在第2版以上,所以我嘗試sudo gem update --system
安裝 RubyGems 3.2.27。
回溯(最近一次呼叫)。
3: from setup.rb:22:in<main>'
2: from setup.rb:22:in require'
1: from /var/lib/gems/2.5.0/gems/rubygems-update3.2. 27/lib/rubygems.rb:1328:in <top(必填)>'
/var/lib/gems/2.5.0/gems/rubygems-update-3.2.27/lib/rubygems.rb:1341:in rescue in <top (required)>': uninitialized constant Gem::BasicSpecification(NameError)。
加載rubygems/defaults/operating_system.rb檔案導致了一個錯誤。這個檔案屬于你的作業系統,不是由 rubygems 上游擁有。請找出這個檔案屬于哪個作業系統包 并按照你的作業系統的指導原則報告問題 并尋求的幫助。
我真的不知道該怎么做,而且我不能開始使用rails,這真是太遺憾了。
uj5u.com熱心網友回復:
根據你安裝ruby的方式(rvm, rbenv, asdf, 系統級安裝),你可能需要將bundle exec加到你的ruby命令中:
bundle exec rails console
這樣,bundle將限制執行你的Gemfile.lock中宣告的寶石,可能包括bundle版本。
你可能在全球范圍內安裝了rails可執行程式,它可能使用不同版本的ruby和rubygems。
。
更新(關于以用戶友好的方式安裝 ruby 的痛苦):
我絕對建議你安裝一些用戶級的工具鏈,如rvm或asdf,并對ruby版本進行完全控制。你不應該sudo任何東西來運行 ruby 和 rails 應用程式。
進入rvm或asdf網站,按照說明在你的作業系統中安裝它們,你就可以控制你的ruby了。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/322778.html
標籤:
