Linuxbrew on Travis CI - travis-ci

I'm trying to install linuxbrew on Travis CI, and it fails for a reason I don't understand. Travis CI claims:
default ruby version
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
but when my .travis.yml file does a:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
It fails at:
HEAD is now at 851177a29 docs: update gems. (#569)
/usr/lib/ruby/1.9.1/rubygems/version.rb:191:in `strip!': can't modify frozen String (RuntimeError)
from /usr/lib/ruby/1.9.1/rubygems/version.rb:191:in `initialize'
from -e:1:in `new'
from -e:1:in `<main>'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb:12:in `<main>': Homebrew must be run under Ruby 2.3! You're running 1.9.3. (RuntimeError)
Failed during: /home/linuxbrew/.linuxbrew/bin/brew update --force
I think this used to work (last year), but all of a sudden its failing. How do I install Linuxbrew on Travis CI on "trusty"?
Edit
Here's my .travis.yml
language: cpp
sudo: required
dist: trusty
before_install:
- sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
End Edit
Thanks.

It appears as though Linuxbrew on Travis CI has a problem identifying which version of Ruby is installed. To fix use the alternative install method of:
git clone https://github.com/Linuxbrew/brew.git ~/.linuxbrew
export HOMEBREW_FORCE_VENDOR_RUBY=1
in the before_install section

Related

Ruby version `ruby-3.1.2' is not installed after spring stop

Truly I don't get it what is wrong. I've got fresh project with Rails 7 and Ruby 3.1.2 which I thought I had installed successfully, based on my iTerm2 console:
$ ruby --version
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin21]
But after firing up the command spring stop inside my project path I'm getting this weirdo:
➜ merchant-portal git:(main)$ spring stop
rbenv: version `ruby-3.1.2' is not installed (set by /Users/some_user/merchant-portal/.ruby-version)
What's going on?
I tried installing the Ruby 3.1.2 again but I'm getting another weirdo:
$ rbenv install 3.1.2
Downloading ruby-3.1.2.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.2.tar.gz
Installing ruby-3.1.2...
ruby-build: using readline from homebrew
BUILD FAILED (macOS 12.5 using ruby-build 20220726)
Inspect or clean up the working tree at /var/folders/bw/rs138g1n5zv_qwn7_7kggc9r0000gq/T/ruby-build.20220801173008.20865.CTLYIi
Results logged to /var/folders/bw/rs138g1n5zv_qwn7_7kggc9r0000gq/T/ruby-build.20220801173008.20865.log
Last 10 log lines:
The Ruby yaml extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
Configure options used:
--prefix=/Users/some_user/.rbenv/versions/3.1.2
--with-openssl-dir=/Users/some_user/.rbenv/versions/3.1.2/openssl
--enable-shared
--with-readline-dir=/usr/local/opt/readline
CC=clang
LDFLAGS=-L/Users/some_user/.rbenv/versions/3.1.2/lib
CPPFLAGS=-I/Users/some_user/.rbenv/versions/3.1.2/include
I've tried to reinstall xcode with:
$ rm -rf /Library/Developer/CommandLineTools
$ xcode-select --install
(...)
Done
$ xcode-select -p
/Applications/Xcode.app/Contents/Developer
And again reinstall Ruby 3.1.2 but it shows me the same error:
$ rbenv install 3.1.2
(...)
BUILD FAILED (macOS 12.5 using ruby-build 20220726)
(...)
Last 10 log lines:
The Ruby yaml extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
(...)
I've also tried to:
RUBY_CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl` --with-readline-dir=`brew --prefix readline` --with-libyaml-dir=`brew --prefix libyaml`" rbenv install 3.1.2
But it shows me the same error.

Rails is not currently installed on this system - High Sierra, rbenv

To start I follow the exact steps from Setup Ruby On Rails on
macOS 10.13 High Sierra, just like I have with every other version of mac/ubuntu.
So basically install homebrew, install rbenv ruby-build
add the following to bash profile and source it:
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
then do
rbenv install 2.5.1
rbenv global 2.5.1
ruby -v
outputs:
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
do a which ruby to to make sure:
/Users/pdavies/.rbenv/shims/ruby
run gem install
gem install rails -v 5.2.0
which outputs:
Successfully installed rails-5.2.0
Parsing documentation for rails-5.2.0
Done installing documentation for rails after 0 seconds
1 gem installed
then a rehash and check version:
rbenv rehash
rails -v
outputs:
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
found anther issue that suggested adding:
export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"
eval "$(rbenv init -)"
to the bash profile, did that sourced it and tried again still nothing. to check the output of echo $PATH was:
/Users/pdavies/.rbenv/shims:/Users/pdavies/.rbenv/bin:/Users/pdavies/.rbenv/shims:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin
Just to make sure i also did which gem incase i wasnt using the right one, output:
/Users/pdavies/.rbenv/shims/gem
when I do a which rails i get:
/usr/bin/rails
I found some blog that said to delete that, but I cant seem to do that either, i just get:
sudo rm -f /usr/bin/rails
Password:
rm: /usr/bin/rails: Operation not permitted
This is a fresh install of OSX and the only way I can get it work is to downgrade the version of OSX that is installed, which is a pain in the ass!
Any help would be grateful
Thanks

Cocoapods: Failed to connect to GitHub to update the CocoaPods/Specs specs repo

When running pod repo update the following error is generated:
Updating spec repo `master`
[!] Failed to connect to GitHub to update the CocoaPods/Specs specs repo - Please check if you are offline, or that GitHub is down
Using cocoapods 1.0.1
I'm also aware of this: Master spec-repo rate limiting post‑mortem.
Adding --verbose flag to the call shows the ruby call stack:
.rvm/gems/ruby-2.3.0/gems/cocoapods-core-1.0.1/lib/cocoapods-core/github.rb:100:in `modified_since_commit'
.rvm/gems/ruby-2.3.0/gems/cocoapods-core-1.0.1/lib/cocoapods-core/master_source.rb:32:in `requires_update?'
.rvm/gems/ruby-2.3.0/gems/cocoapods-core-1.0.1/lib/cocoapods-core/master_source.rb:14:in `update'
.rvm/gems/ruby-2.3.0/gems/cocoapods-1.0.1/lib/cocoapods/sources_manager.rb:88:in `block (2 levels) in update'
.rvm/gems/ruby-2.3.0/gems/cocoapods-1.0.1/lib/cocoapods/user_interface.rb:63:in `section'
.rvm/gems/ruby-2.3.0/gems/cocoapods-1.0.1/lib/cocoapods/sources_manager.rb:87:in `block in update'
.rvm/gems/ruby-2.3.0/gems/cocoapods-1.0.1/lib/cocoapods/sources_manager.rb:86:in `each'
.rvm/gems/ruby-2.3.0/gems/cocoapods-1.0.1/lib/cocoapods/sources_manager.rb:86:in `update'
.rvm/gems/ruby-2.3.0/gems/cocoapods-1.0.1/lib/cocoapods/command/repo/update.rb:23:in `run'
.rvm/gems/ruby-2.3.0/gems/claide-1.0.0/lib/claide/command.rb:334:in `run'
.rvm/gems/ruby-2.3.0/gems/cocoapods-1.0.1/lib/cocoapods/command.rb:50:in `run'
.rvm/gems/ruby-2.3.0/gems/cocoapods-1.0.1/bin/pod:55:in `<top (required)>'
.rvm/gems/ruby-2.3.0/bin/pod:23:in `load'
.rvm/gems/ruby-2.3.0/bin/pod:23:in `<main>'
.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'
Can't find any way to workaround this and cannot run the project.
One of the major issue is "weak cryptographic standards removed" after 2018 February.
Here a note:
https://github.com/blog/2507-weak-cryptographic-standards-removed
To solve this, first you need to update openssl, then ruby, then cocoapod.
$ which openssl
/usr/bin/openssl
$ openssl version
OpenSSL 0.9.8zh 14 Jan 2016
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
$ brew update
$ brew install openssl
$ brew upgrade openssl
`` If you need to have this software first in your PATH run: echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
$ echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
$ source ~/.bash_profile
$ which openssl
/usr/local/opt/openssl/bin/openssl
$ openssl version
OpenSSL 1.0.2n 7 Dec 2017
$ brew install rbenv ruby-build
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
$ source ~/.bash_profile
$ rbenv install --list
Available versions:
1.8.5-p52
1.8.5-p113
1.8.5-p114
1.8.5-p115
1.8.5-p231
1.8.6
:
2.5.0-rc1
2.5.0
2.5.1
2.6.0-dev
:
$ rbenv install 2.5.1
$ rbenv versions
* system (set by /Users/username/.rbenv/version)
2.5.1
$ ruby --version
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
$ rbenv global 2.5.1
$ rbenv versions
system
* 2.5.1 (set by /Users/username/.rbenv/version)
$ ruby --version
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16]
$ gem install cocoapods -n /usr/local/bin
$ which pod
/usr/local/bin/pod
$ pod --version
1.5.3
now, you can do
$ pod update
source link: https://qiita.com/satoshi-iwaki/items/ed2c267127dcc80baa21
Finally managed to solve it by deleting ./cocoapods/repos/master and running pod install.
The more formal solution would probably go like this:
pod repo remove master
pod setup
pod install
If pod install fails after performing the first two steps, you may need to delete your Podfile.lock.
Why it initially failed to connect to Github is beyond me.
You can try this:
$sudo rm -fr ~/.cocoapods/repos/master
$pod setup
$pod install
but in my case I had to:
delete the Podfile.lock and then
$pod install
A another solution similar to Max's and Adem's in this thread is found in a CocoaPods issue:
brew install ruby
sudo gem install cocoapods
Verify that you're using the latest and correct Ruby with:
ruby --version
which ruby
Should be using /usr/local/bin/ruby
Reason:
It turns out that Github updated to only support TLS 1.2 on Feb 22nd. Older versions of MacOS before High Sierra come preinstalled with Ruby 2.0. This version uses OpenSSL 0.9.8 which "will fail with servers supporting only TLS 1.2."
Updating to the latest Ruby (2.5) and latest CocoaPods (1.4) fixed this for me without having to do anything with openssl (Ruby updates openssl). This is a good solution if you don't want to update to High Sierra just yet.
I also encountered the same issue. In my scene, i used a mirror repo (hosted elsewhere) of cocoapods specs on github. When i updated the specs repo, it worked!
cd ~/.cocoapods/repos/master
git pull
This worked like magic
$sudo rm -fr ~/.cocoapods/repos/master
$pod setup
$pod install
Otherwise
$pod setup
Ctrl +C
cd ~/.cocoapods/repos
$git clone --depth 1 https://github.com/CocoaPods/Specs.git master
A slightly simpler solution from Adem's that doesn't use rbenv:
brew install openssl
brew upgrade openssl
brew install ruby
brew link --overwrite ruby
Finally, make sure you don't have your PATH variable set to have /usr/local/bin after $PATH. Your PATH export in ~/.bash_profile should look similar to this:
export PATH=/usr/local/bin:$PATH
This worked for me:
Remove Podfile.lock
Run pod install
Just update cocoapods: sudo gem install cocoapods
If someone has these issues on Circle CI I was struggling with this for a day almost.
In the end I think the best way is to use their provided solution to download from their servers.
curl https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash -s cf
From this link you can see that one of the cocoapods core contributor says that it's fine:
The CocoaPods repo cache is updated roughly every 30 mins, which is usually frequent enough to only miss the last 6 pushes to the Specs repo.
https://discuss.circleci.com/t/best-practice-for-use-of-cached-cocoapods-specs/18897/2
I did next in Terminal:
brew install openssl
if you don't have home brew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
and repeat p.1
export PATH="/usr/local/opt/openssl/bin:$PATH"
openssl version
Output:OpenSSL 1.0.2n 7 Dec 2017
pod update
I was also facing the same problem.
I solved it only by accessing two commands from terminal.
sudo gem uninstall nanaimo
and then
sudo gem install nanaimo
Hope so it will help.
Remove all of cocoapods package. See here for information on how to do this.
Then reinstall cocoapods. $ sudo gem install cocoapods
For me the below commands fixed the issue
Removing cocoapods from mac
sudo gem uninstall cocoapods
Installing cocoapods on mac
sudo gem install cocoapods
Anyone facing any similar issue where the remote hangs-up prematurely, use ssh to clone the repo instead.
git clone git#github.com:CocoaPods/Specs.git master.
In order to use SSH to clone a GitHub repo, you need to have a GitHub account and have your SSH keys associated with it.
Follow their documentation here.
update ruby and cocoapods.
check ruby version in the cocoapods env.
use
pod env
rbenv global x.x.x
ruby -v
change ruby version. If not working, watch this rbenv not changing ruby version
check ruby version in the cocoapods env. If not changed,
which pod
make sure your pod path is /usr/local/bin/pod,if not
export PATH=/usr/local/bin:$PATH

Cucumber on Travis CI container

I am trying to get Cucumber to run tests on my builds on Travis CI with following minimal .travis.yml:
language: ruby
sudo: required
services: docker
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq cucumber
script:
- cucumber --version
But the build fails with
/usr/local/rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- cucumber/rspec/disable_option_parser (LoadError)
from /usr/local/rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/bin/cucumber:10:in `<main>'
Do I need to install other packages than cucumber?
It seems all the packages are being installed, the problem here I think is that sudo apt-get install -qq cucumber installed ruby 1.9.3 and then cucumber (check the log), calling cucumber tries to execute using ruby 2.2 (travis default)
Maybe you should stick to using bundler or rake to install the cuke.

brew update and or brew doctor throwing errors

When I try brew update, I get the following error. How can I fix it
~$ brew update
Error: undefined method `close!' for nil:NilClass
Please report this bug:
https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Troubleshooting.md#troubleshooting
/usr/local/Library/Homebrew/extend/pathname.rb:129:in `ensure in atomic_write'
/usr/local/Library/Homebrew/extend/pathname.rb:129:in `atomic_write'
/usr/local/Library/Homebrew/cmd/untap.rb:42:in `unlink_tap_formula'
/usr/local/Library/Homebrew/cmd/update.rb:24:in `update'
/usr/local/Library/brew.rb:136:in `<main>'
Here is the exact issue closed on homebrew github repo brew update gives NilClass error.
So here's how I got it working:
Full uninstall of brew. For me I just wiped my /usr/local directory
as this is a clean machine at the moment.
Full uninstall of RVM.
Make sure my command line tools are up to date "xcode-select --install"
su to admin account and install Homebrew
update /usr/local and all sub files/dirs to have my account as owner - "sudo chown -R jmcdonald ."
"brew install ..." for all of these RVM/Ruby required libs: autoconf,
automake, libtool, apple-gcc42, libyaml, libxslt, libksba, openssl
(apple-gcc42 gave me errors but doesn't seem to have impact).
Exit su and install RVM.
Install a ruby: "rvm install 1.9.3"
I would guess I could have gotten it working without removals but wanted to make sure I had a clean setup.

Resources