在 /root 和 /home 中安装新发行版后的 Rails 开发环境保持不变
Posted
技术标签:
【中文标题】在 /root 和 /home 中安装新发行版后的 Rails 开发环境保持不变【英文标题】:Rails development environment after new distro is installed in /root and /home kept same 【发布时间】:2016-05-25 07:49:53 【问题描述】:我将发行版从 Ubuntu 更改为 Elementary OS。我保留了我的/home
目录,这样我就不必安装任何东西了。
我按照 GoRail 的 guide 安装 Rails。
现在,当我尝试重新安装同一指南中的所有内容时,结果发现 RVM、Ruby 和 Rails 已经存在。
➜ sample_app git:(master) ✗ rails -v
Rails 4.2.2
但是,当我转到我的旧项目并尝试启动服务器时,它会引发以下错误:
➜ sample_app git:(master) ✗ rails s
/home/abhimanyuaryan/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)
from /home/abhimanyuaryan/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /home/abhimanyuaryan/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
from /home/abhimanyuaryan/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
from /home/abhimanyuaryan/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
from /home/abhimanyuaryan/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
from /home/abhimanyuaryan/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
from /home/abhimanyuaryan/Public/RoR/sample_app/config/application.rb:7:in `<top (required)>'
from /home/abhimanyuaryan/.rvm/gems/ruby-2.2.3/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:78:in `require'
from /home/abhimanyuaryan/.rvm/gems/ruby-2.2.3/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:78:in `block in server'
from /home/abhimanyuaryan/.rvm/gems/ruby-2.2.3/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /home/abhimanyuaryan/.rvm/gems/ruby-2.2.3/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:75:in `server'
from /home/abhimanyuaryan/.rvm/gems/ruby-2.2.3/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/abhimanyuaryan/.rvm/gems/ruby-2.2.3/gems/railties-4.2.2/lib/rails/commands.rb:17:in `<top (required)>'
from /home/abhimanyuaryan/Public/RoR/sample_app/bin/rails:9:in `require'
from /home/abhimanyuaryan/Public/RoR/sample_app/bin/rails:9:in `<top (required)>'
from /home/abhimanyuaryan/.rvm/gems/ruby-2.2.3/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in `load'
from /home/abhimanyuaryan/.rvm/gems/ruby-2.2.3/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in `call'
from /home/abhimanyuaryan/.rvm/gems/ruby-2.2.3/gems/spring-1.1.3/lib/spring/client/command.rb:7:in `call'
from /home/abhimanyuaryan/.rvm/gems/ruby-2.2.3/gems/spring-1.1.3/lib/spring/client.rb:26:in `run'
from /home/abhimanyuaryan/.rvm/gems/ruby-2.2.3/gems/spring-1.1.3/bin/spring:48:in `<top (required)>'
from /home/abhimanyuaryan/.rvm/gems/ruby-2.2.3/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `load'
from /home/abhimanyuaryan/.rvm/gems/ruby-2.2.3/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `<top (required)>'
from /home/abhimanyuaryan/Public/RoR/sample_app/bin/spring:13:in `require'
from /home/abhimanyuaryan/Public/RoR/sample_app/bin/spring:13:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
➜ sample_app git:(master) ✗
【问题讨论】:
您在使用 RVM 吗?您是否检查了您的主目录,您是否像安装新操作系统之前一样拥有可用的 gemset? @RameshKumarThiyagarajan 是的,我正在使用 RVM。我不知道我是 Rails 的新手。我应该怎么做才能检查宝石? 在创建 gemset 后尝试bundle install
【参考方案1】:
根据您的错误信息
There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)
您似乎没有安装 NodeJS。运行
sudo apt-get install nodejs
bundle install
见“There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)”。
【讨论】:
以上是关于在 /root 和 /home 中安装新发行版后的 Rails 开发环境保持不变的主要内容,如果未能解决你的问题,请参考以下文章
Ubuntu18.04中安装virtualenv和virtualenvwrapper