Sev*_*rin 6 ruby ruby-on-rails node.js gitlab gitlab-ci
我正在尝试为我的Ruby on Rails项目设置Gitlab CI,但遇到了一个我不知道如何解决的错误.
该应用程序在Ruby 2.3.1,Rails 5.0上运行,并使用postgreSQL数据库.
我当前的.gitlab.ci.yml文件如下所示:
# https://hub.docker.com/r/library/ruby/tags/
image: "ruby:2.3.0"
# Pick zero or more services to be used on all builds.
# Only needed when using a docker container to run your tests in.
# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-service
services:
- redis:latest
- postgres:latest
- node:latest
# This is a basic example for a gem or script which doesn't use
# services such as redis or postgres
before_script:
- gem install bundler # Bundler is not installed with the image
- bundle install -j $(nproc) # Install dependencies
rubocop:
script:
- rubocop
rspec:
script:
- rspec spec
rails:
script:
- rails db:migrate
- rspec spec
Run Code Online (Sandbox Code Playgroud)
所以它应该使用NodeJS作为运行时.但是,我收到以下错误:
$ rails db:migrate
rails aborted!
Bundler::GemRequireError: There was an error while trying to load the gem 'uglifier'.
Gem Load Error is: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
Backtrace for gem load error is:
/usr/local/bundle/gems/execjs-2.7.0/lib/execjs/runtimes.rb:58:in `autodetect'
/usr/local/bundle/gems/execjs-2.7.0/lib/execjs.rb:5:in `<module:ExecJS>'
/usr/local/bundle/gems/execjs-2.7.0/lib/execjs.rb:4:in `<top (required)>'
/usr/local/bundle/gems/activesupport-5.0.0.rc2/lib/active_support/dependencies.rb:293:in `require'
/usr/local/bundle/gems/activesupport-5.0.0.rc2/lib/active_support/dependencies.rb:293:in `block in require'
/usr/local/bundle/gems/activesupport-5.0.0.rc2/lib/active_support/dependencies.rb:259:in `load_dependency'
/usr/local/bundle/gems/activesupport-5.0.0.rc2/lib/active_support/dependencies.rb:293:in `require'
/usr/local/bundle/gems/uglifier-3.0.0/lib/uglifier.rb:5:in `<top (required)>'
Run Code Online (Sandbox Code Playgroud)
你需要javascript运行时(nodejs),安装它们.
Ubuntu用户
sudo apt-get install nodejs
Run Code Online (Sandbox Code Playgroud)
CentOS/RedHat用户
sudo yum install nodejs
Run Code Online (Sandbox Code Playgroud)
如果你无法安装,nodejs你可以使用therubyracergem.存储库中的描述:
将V8 JavaScript解释器嵌入到Ruby中.
添加此行 Gemfile
gem 'therubyracer', platforms: :ruby
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2089 次 |
| 最近记录: |