Github actions rails 命令"/bin/ruby: invalid option -: (-h will show valid options) (RuntimeError)"



我正在尝试实现Github Actions,但无法运行rails命令。

在github工作流中运行bundle exec rakebundle exec rails db:create时引发错误。

Run bundle exec rake rails db:setup
bundle exec rake rails db:setup
shell: /bin/bash -e {0}
env:
PATH: /home/runner/.rubies/ruby-2.6.5/bin:/usr/share/rust/.cargo/bin:/home/runner/.config/composer/vendor/bin:/home/runner/.dotnet/tools:/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin
RAILS_ENV: test
POSTGRES_HOST: localhost
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_PORT: 5432
RUBYOPT: -W:no-deprecated -W:no-experimental
/home/runner/.rubies/ruby-2.6.5/bin/ruby: invalid option -:  (-h will show valid options) (RuntimeError)
##[error]Process completed with exit code 1.

这是我的ruby.yml文件:

name: Ruby
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- "5432:5432"
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6.5
- name: Install library for postgres
run: sudo apt-get install libpq-dev
- name: Install dependencies
run: bundle install
- name: Setup Database
run: bundle exec rake rails db:setup
env:
RAILS_ENV: test
POSTGRES_HOST: localhost
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_PORT: 5432
RUBYOPT: "-W:no-deprecated -W:no-experimental"
- name: Run tests
env:
RAILS_ENV: test
POSTGRES_HOST: localhost
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_PORT: 5432
RUBYOPT: "-W:no-deprecated -W:no-experimental"
run: bundle exec rake
- name: Ensure that assets compile correctly
run: bundle exec rails assets:precompile

谢谢大家!

RUBYOPT='-W:no-deprecated不适用于Ruby版本<2.7.

更改

ruby-version: 2.6.5

ruby-version: 2.7.0

我不知道这是否能给你任何帮助。但是,你可以试着根据我的发现做我所做的事情。

转到应用程序的根目录。运行pwd命令,查看路径中是否有空间。根据您的问题,它可能在:字符之前有一个空格。

我重命名了包含空间的文件夹名称,一切都很好

我希望它能帮助

相关内容

最新更新