Je suis "Mise en route avec Ruby sur Heroku", mais lorsque j'essaie d'exécuter l'application de démonstration localement avec
$ bundle exec rake db:create db:migrate
Je reçois
sam@samoliver:~/Ruby-getting-started$ bundle exec rake db:create db:migrate --trace
rake aborted!
Bundler::GemRequireError: There was an error while trying to load the gem 'uglifier'.
/home/sam/.rvm/gems/Ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require'
/home/sam/.rvm/gems/Ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
/home/sam/.rvm/gems/Ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:72:in `each'
/home/sam/.rvm/gems/Ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:72:in `block in require'
/home/sam/.rvm/gems/Ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:61:in `each'
/home/sam/.rvm/gems/Ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:61:in `require'
/home/sam/.rvm/gems/Ruby-2.2.3/gems/bundler-1.11.0/lib/bundler.rb:99:in `require'
/home/sam/Ruby-getting-started/config/application.rb:7:in `<top (required)>'
/home/sam/Ruby-getting-started/Rakefile:4:in `require'
/home/sam/Ruby-getting-started/Rakefile:4:in `<top (required)>'
/home/sam/.rvm/rubies/Ruby-2.2.3/lib/Ruby/2.2.0/rake/rake_module.rb:28:in `load'
/home/sam/.rvm/rubies/Ruby-2.2.3/lib/Ruby/2.2.0/rake/rake_module.rb:28:in `load_rakefile'
/home/sam/.rvm/rubies/Ruby-2.2.3/lib/Ruby/2.2.0/rake/application.rb:689:in `raw_load_rakefile'
/home/sam/.rvm/rubies/Ruby-2.2.3/lib/Ruby/2.2.0/rake/application.rb:94:in `block in load_rakefile'
/home/sam/.rvm/rubies/Ruby-2.2.3/lib/Ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/home/sam/.rvm/rubies/Ruby-2.2.3/lib/Ruby/2.2.0/rake/application.rb:93:in `load_rakefile'
/home/sam/.rvm/rubies/Ruby-2.2.3/lib/Ruby/2.2.0/rake/application.rb:77:in `block in run'
/home/sam/.rvm/rubies/Ruby-2.2.3/lib/Ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/home/sam/.rvm/rubies/Ruby-2.2.3/lib/Ruby/2.2.0/rake/application.rb:75:in `run'
/home/sam/.rvm/rubies/Ruby-2.2.3/bin/rake:33:in `<main>'
ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
/home/sam/.rvm/gems/Ruby-2.2.3/gems/execjs-2.2.2/lib/execjs/runtimes.rb:51:in `autodetect'
/home/sam/.rvm/gems/Ruby-2.2.3/gems/execjs-2.2.2/lib/execjs.rb:5:in `<module:ExecJS>'
/home/sam/.rvm/gems/Ruby-2.2.3/gems/execjs-2.2.2/lib/execjs.rb:4:in `<top (required)>'
/home/sam/.rvm/gems/Ruby-2.2.3/gems/uglifier-2.5.3/lib/uglifier.rb:3:in `require'
/home/sam/.rvm/gems/Ruby-2.2.3/gems/uglifier-2.5.3/lib/uglifier.rb:3:in `<top (required)>'
/home/sam/.rvm/gems/Ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:77:in `require'
/home/sam/.rvm/gems/Ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:77:in `block (2 levels) in require'
/home/sam/.rvm/gems/Ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:72:in `each'
/home/sam/.rvm/gems/Ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:72:in `block in require'
/home/sam/.rvm/gems/Ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:61:in `each'
/home/sam/.rvm/gems/Ruby-2.2.3/gems/bundler-1.11.0/lib/bundler/runtime.rb:61:in `require'
/home/sam/.rvm/gems/Ruby-2.2.3/gems/bundler-1.11.0/lib/bundler.rb:99:in `require'
/home/sam/Ruby-getting-started/config/application.rb:7:in `<top (required)>'
/home/sam/Ruby-getting-started/Rakefile:4:in `require'
/home/sam/Ruby-getting-started/Rakefile:4:in `<top (required)>'
/home/sam/.rvm/rubies/Ruby-2.2.3/lib/Ruby/2.2.0/rake/rake_module.rb:28:in `load'
/home/sam/.rvm/rubies/Ruby-2.2.3/lib/Ruby/2.2.0/rake/rake_module.rb:28:in `load_rakefile'
/home/sam/.rvm/rubies/Ruby-2.2.3/lib/Ruby/2.2.0/rake/application.rb:689:in `raw_load_rakefile'
/home/sam/.rvm/rubies/Ruby-2.2.3/lib/Ruby/2.2.0/rake/application.rb:94:in `block in load_rakefile'
/home/sam/.rvm/rubies/Ruby-2.2.3/lib/Ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/home/sam/.rvm/rubies/Ruby-2.2.3/lib/Ruby/2.2.0/rake/application.rb:93:in `load_rakefile'
/home/sam/.rvm/rubies/Ruby-2.2.3/lib/Ruby/2.2.0/rake/application.rb:77:in `block in run'
/home/sam/.rvm/rubies/Ruby-2.2.3/lib/Ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/home/sam/.rvm/rubies/Ruby-2.2.3/lib/Ruby/2.2.0/rake/application.rb:75:in `run'
/home/sam/.rvm/rubies/Ruby-2.2.3/bin/rake:33:in `<main>'
sam@samoliver:~/Ruby-getting-started$
J'ai essayé de supprimer et d'ajouter à nouveau 'uglifier' (2.5.3) sans effet et j'ai 'therubyracer' installé, donc je ne comprends pas de quoi se plaint ExecJS.
Gemfile
source 'https://rubygems.org'
Ruby '2.2.3'
# Bundle Edge Rails instead: gem 'Rails', github: 'Rails/rails'
gem 'Rails', '4.2.3'
# Use postgresql as the database for Active Record
gem 'pg'
gem 'Rails_12factor', group: :production
# Use SCSS for stylesheets
gem 'sass-Rails', '~> 5.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-Rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :Ruby
# Use jquery as the JavaScript library
gem 'jquery-Rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/Rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/Rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:Rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/Rails/spring
gem 'spring', group: :development
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
gem 'puma'
# Use Capistrano for deployment
# gem 'capistrano-Rails', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
installez nodejs
apt-get install nodejs
décommenter la ligne ci-dessous dans Gemfile
#gem 'therubyracer', platforms: :Ruby
courir dans le terminal
bundle install
Uglifier est un compresseur JavaScript, il a donc besoin d'un runtime javascript, essayez d'installer nodejs
Exécutez ceci pour installer NodeJS dans Ubuntu
Sudo apt-get install nodejs
ou
brew install nodejs
si vous êtes sous OSX.
Essaye ça:
gem update --system 1.4.2
J'avais le même problème. Je devais aller dans mon dossier racine (sur l'utilisation d'ubuntu
Sudo su)
À partir de là, utilisez apt-get install nodejs
, puis quittez la racine et exécutez bundle install
alors vous devriez pouvoir exécuter rake db:migrate