《Run Travis build locally》一文问题解决

项目需要在本地搭建Travis。按照下述地址进行安装,中间出现了一堆问题,现将问题记录下来方便大家和自己以后参考。

https://gist.github.com/fulldecent/d84cd1abdcc6930865d1b862c4aed917

也可以参考:

https://forums.habitat.sh/t/testing-travis-ci-workflows-locally-in-docker/630

 

问题1

$ rvm install 2.3.0

xxxxxxxxxxxxxxx not permitted

描述:执行该语句提示权限问题的时候,但是rvm又不能使用sudo

解决方法

$ rvm autolibs disable
$ rvm requirements # manually install these
$ rvm install ruby

问题2

$ gem install travis

ERROR:  Could not find a valid gem 'travis' (>= 0), here is why:Unable to pull data from 'https://rubygems.org/

解决方法

$ gem sources -r https://rubygems.org/
$ gem sources -a http://rubygems.org/ 

第二条语句执行时间较长,请耐心等待。

问题3

$ bundle install
Fetching source index from https://rubygems.org/

Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from https://rubygems.org/
Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from https://rubygems.org/
Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from https://rubygems.org/
Could not fetch specs from https://rubygems.org/

// 可以使用bundle install --verbose来查看具体的错误信息

解决方法

参考:https://gems.ruby-china.com/

说明:在我的本地必须执行下面的语句,即更新Gem源代码镜像才起作用

bundle config mirror.https://rubygems.org https://gems.ruby-china.com

问题4

重新进入container之后,再执行gem install就出现这个问题。

Gemfile syntax error on line 15: unknown type of %string
...er', require: false, group: %i[development test]
...                               ^
on line 15: syntax error, unexpected $end
...er', require: false, group: %i[development test]
...                               ^

解决方法:再次执行上述的安装过程。

cd ~/.travis/travis-build
gem install travis
travis # to create ~/.travis
ln -s `pwd` ~/.travis/travis-build
bundle install

问题5

$ bundle install
Fetching gem metadata from https://gems.ruby-china.com/........
Fetching https://github.com/joshk/jemalloc-rb
Fetching https://github.com/eric/metriks-librato_metrics
Fetching https://github.com/travis-ci/travis-github_apps
Fetching https://github.com/travis-ci/travis-rollout
Fetching https://github.com/travis-ci/travis-support
Fetching rake 12.3.1

Retrying download gem from https://gems.ruby-china.com/ due to error (2/4): Gem::RemoteFetcher::UnknownHostError timed out (https://gems.ruby-china.com/gems/rake-12.3.1.gem)
Retrying download gem from https://gems.ruby-china.com/ due to error (3/4): Gem::RemoteFetcher::UnknownHostError timed out (https://gems.ruby-china.com/gems/rake-12.3.1.gem)
Retrying download gem from https://gems.ruby-china.com/ due to error (4/4): Gem::RemoteFetcher::UnknownHostError timed out (https://gems.ruby-china.com/gems/rake-12.3.1.gem)
Gem::RemoteFetcher::UnknownHostError: timed out
(https://gems.ruby-china.com/gems/rake-12.3.1.gem)
An error occurred while installing rake (12.3.1), and Bundler
cannot continue.
Make sure that `gem install rake -v '12.3.1' --source 'https://rubygems.org/'`
succeeds before bundling.

解决方法

// 参照错误提示安装rake
gem install rake -v '12.3.1'

问题6

$ travis compile > ci.sh
/home/travis/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- travis/support (LoadError)
        from /home/travis/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /home/travis/.travis/travis-build/lib/travis/build.rb:1:in `<top (required)>'
        from /home/travis/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /home/travis/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /home/travis/.travis/travis-build/init.rb:11:in `setup'
        from /home/travis/.rvm/gems/ruby-2.3.0/gems/travis-1.8.10/lib/travis/cli/command.rb:197:in `execute'
        from /home/travis/.rvm/gems/ruby-2.3.0/gems/travis-1.8.10/lib/travis/cli.rb:64:in `run'
        from /home/travis/.rvm/gems/ruby-2.3.0/gems/travis-1.8.10/bin/travis:18:in `<top (required)>'
        from /home/travis/.rvm/gems/ruby-2.3.0/bin/travis:23:in `load'
        from /home/travis/.rvm/gems/ruby-2.3.0/bin/travis:23:in `<main>'
        from /home/travis/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
        from /home/travis/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'

解决方法

cd ~/.travis/

git clone https://github.com/travis-ci/travis-support.git
cd travis-support
gem build travis-support.gemspec # Or whatever the filename is, I'm doing this from memory
gem install travis-support

// Likely if you get the travis-support error, you will get travis-rollout and travis-github_apps errors too. Just follow the same steps.
// but I do not

git clone https://github.com/travis-ci/travis-rollout.git
cd travis-rollout
gem build travis-rollout.gemspec # Or whatever the filename is, I'm doing this from memory
gem install travis-rollout

git clone https://github.com/travis-ci/travis-github_apps.git
cd travis-github_apps
gem build travis-github_apps.gemspec # Or whatever the filename is, I'm doing this from memory
gem install travis-github_apps

问题7

$ travis compile > ci.sh
/home/travis/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- active_support/core_ext/module/aliasing (LoadError)
        from /home/travis/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /home/travis/.rvm/gems/ruby-2.3.0/gems/travis-support-0.0.1/lib/travis/support/assertions.rb:1:in `<top (required)>'
        from /home/travis/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /home/travis/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /home/travis/.rvm/gems/ruby-2.3.0/gems/travis-support-0.0.1/lib/travis/support.rb:5:in `<module:Travis>'
        from /home/travis/.rvm/gems/ruby-2.3.0/gems/travis-support-0.0.1/lib/travis/support.rb:4:in `<top (required)>'
        from /home/travis/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:130:in `require'
        from /home/travis/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:130:in `rescue in require'
        from /home/travis/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:35:in `require'
        from /home/travis/.travis/travis-build/lib/travis/build.rb:1:in `<top (required)>'
        from /home/travis/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /home/travis/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /home/travis/.travis/travis-build/init.rb:11:in `setup'
        from /home/travis/.rvm/gems/ruby-2.3.0/gems/travis-1.8.10/lib/travis/cli/command.rb:197:in `execute'
        from /home/travis/.rvm/gems/ruby-2.3.0/gems/travis-1.8.10/lib/travis/cli.rb:64:in `run'
        from /home/travis/.rvm/gems/ruby-2.3.0/gems/travis-1.8.10/bin/travis:18:in `<top (required)>'
        from /home/travis/.rvm/gems/ruby-2.3.0/bin/travis:23:in `load'
        from /home/travis/.rvm/gems/ruby-2.3.0/bin/travis:23:in `<main>'
        from /home/travis/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
        from /home/travis/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'

解决方法: 待解决

猜你喜欢

转载自blog.csdn.net/shuizhongmose/article/details/98770427