运行设计时Devise会出错:在rails应用程序中安装

时间:2015-12-15 16:29:39

标签: ruby-on-rails ruby devise

我正在使用ruby 2.2.3和rails 4.2.5。我无法在我的项目上运行rails generate devise:install。 Bundler抛出了一个错误。错误就像是

rails g devise:install
/home/suyesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.11.1/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/suyesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.11.1/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /home/suyesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.11.1/lib/bundler/runtime.rb:72:in `each'
    from /home/suyesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.11.1/lib/bundler/runtime.rb:72:in `block in require'
    from /home/suyesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.11.1/lib/bundler/runtime.rb:61:in `each'
    from /home/suyesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.11.1/lib/bundler/runtime.rb:61:in `require'
    from /home/suyesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.11.1/lib/bundler.rb:99:in `require'
    from /home/suyesh/Desktop/petrohub/config/application.rb:7:in `<top (required)>'
    from /home/suyesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.6.0/lib/spring/application.rb:82:in `require'
    from /home/suyesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.6.0/lib/spring/application.rb:82:in `preload'
    from /home/suyesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.6.0/lib/spring/application.rb:143:in `serve'
    from /home/suyesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.6.0/lib/spring/application.rb:131:in `block in run'
    from /home/suyesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.6.0/lib/spring/application.rb:125:in `loop'
    from /home/suyesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.6.0/lib/spring/application.rb:125:in `run'
    from /home/suyesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.6.0/lib/spring/application/boot.rb:18:in `<top (required)>'
    from /home/suyesh/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /home/suyesh/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from -e:1:in `<main>'

这是我的宝石清单

actionmailer (4.2.5)
actionpack (4.2.5)
actionview (4.2.5)
activejob (4.2.5)
activemodel (4.2.5)
activerecord (4.2.5)
activesupport (4.2.5)
arel (6.0.3)
autoprefixer-rails (6.1.2)
bcrypt (3.1.10)
bigdecimal (1.2.7, 1.2.6)
binding_of_caller (0.7.2)
bootstrap-sass (3.3.6)
builder (3.2.2)
bundler (1.11.1, 1.11.0)
byebug (8.2.1)
coffee-rails (4.1.0)
coffee-script (2.4.1)
coffee-script-source (1.10.0)
concurrent-ruby (1.0.0)
debug_inspector (0.0.2)
devise (3.5.3)
diff-lcs (1.2.5)
domain_name (0.5.25)
erubis (2.7.0)
execjs (2.6.0)
globalid (0.3.6)
http-cookie (1.0.2)
i18n (0.7.0)
io-console (0.4.3)
jbuilder (2.3.2)
jquery-rails (4.0.5)
json (1.8.3, 1.8.1)
loofah (2.0.3)
mail (2.6.3)
mechanize (2.7.3)
mime-types (3.0, 2.99)
mime-types-data (3.2015.1120)
mini_portile2 (2.0.0)
minitest (5.8.3, 5.4.3)
multi_json (1.11.2)
net-http-digest_auth (1.4)
net-http-persistent (2.9.4)
nokogiri (1.6.7)
ntlm-http (0.1.1)
orm_adapter (0.5.0)
power_assert (0.2.6, 0.2.2)
psych (2.0.16, 2.0.8)
rack (1.6.4)
rack-protection (1.5.3)
rack-test (0.6.3)
rails (4.2.5)
rails-deprecated_sanitizer (1.0.3)
rails-dom-testing (1.0.7)
rails-html-sanitizer (1.0.2)
railties (4.2.5)
rake (10.4.2)
rdoc (4.2.0)
responders (2.1.0)
rspec-core (3.4.1)
rspec-expectations (3.4.0)
rspec-mocks (3.4.0)
rspec-rails (3.4.0)
rspec-support (3.4.1)
rubygems-update (2.5.1)
sass (3.4.20)
sass-rails (5.0.4)
sdoc (0.4.1)
sinatra (1.4.6)
spring (1.6.0)
sprockets (3.5.2)
sprockets-rails (2.3.3)
sqlite3 (1.3.11)
test-unit (3.1.5, 3.0.8)
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.1)
turbolinks (2.5.3)
tzinfo (1.2.2)
uglifier (2.7.2)
unf (0.1.4)
unf_ext (0.0.7.1)
warden (1.2.4)
web-console (3.0.0, 2.2.1)
webrobots (0.1.1)

当我执行rails generate devise:install时,我一直收到错误。我尝试卸载设计并重新安装它。我甚至尝试卸载uglifier并重新安装。我无法理解造成这个问题的原因是什么?它是捆绑者吗?

6 个答案:

答案 0 :(得分:4)

已经解决了。问题是nodejs。我正在使用nvm来管理我的nodejs,我切换到系统范围的sudo apt-get install nodejs并切换到nvm以使用系统版本并设计开始工作。

答案 1 :(得分:1)

我遇到了同样的问题,因为我这样做了:

bin/spring stop
bin/spring binstub --remove --all
bundle isntall && update

答案 2 :(得分:1)

当我收到该错误时,我发现这三个步骤纠正了这个问题,虽然我不确定如何或为什么:

  1. 卸载gem。
  2. 安装gem,没有特定版本来安装最新版本。
  3. 更新我的gem文件以包含此新版本。
  4. 我正在通过文本学习Ruby on Rails,它让我使用特定版本,但整个事情没有按照预期的那样工作,我发现上面的内容对我有用。在事情最终成功之前,我必须为四颗宝石做这件事。

答案 3 :(得分:0)

您输入错误的主要原因可能是您遗忘了将Gemfile包含在uglifier中。所以,

首先检查Gemfile中是否存在bundle install gem。

之后,再次运行install

然后doctrine: dbal: driver: pdo_mysql host: "%database_host%" port: "%database_port%" dbname: "%database_name%" user: "%database_user%" password: "%database_password%" charset: UTF8 # if using pdo_sqlite as your database driver: # 1. add the path in parameters.yml # e.g. database_path: "%kernel.root_dir%/data/data.db3" # 2. Uncomment database_path in parameters.yml.dist # 3. Uncomment next line: # path: "%database_path%" 设计。

我希望这会有所帮助。

答案 4 :(得分:0)

我不确定这是否是问题,但Devise 3.5.3的依赖关系是:railties&lt; 5,&gt; = 3.2.6 看起来你需要更新这个宝石

答案 5 :(得分:0)

我遇到了同样的问题。通过安装nodejs来修复它现在正在工作:)