bundle exec rake: command not found on Ubuntu 20.04 docker host - bundler

I have a rails app (using the ruby:2.6-alpine base image) in Docker with an entrypoint executing some "bundle exec rake" calls. It runs fine in Ubunto on WSL2 and did run fine in Docker on an Ubuntu 20.04 host until recently. Now it fails on the Ubuntu Server with
bundler: command not found: rake
Install missing gem executables with `bundle install`
Entering the docker container and executing bundle check gives the following result:
The Gemfile's dependencies are satisfied
Executing bundle install results in:
Using rake 13.0.1
Using concurrent-ruby 1.1.8
Using i18n 1.8.9
...
Using webpacker 5.2.1
Bundle complete! 113 Gemfile dependencies, 175 gems now installed.
As you can see, rake is installed, there is nothing to install.
Executing bundle exec rake from the same docker image in Ubuntu on WSL2 it just works as expected.
How can I find out why calling bundle exec rake fails with bundler: command not found: rake in this environment?
Edit
When I create my image with ruby:2.6.7-alpine, it works on both hosts (Ubuntu as well as Ubuntu on WSL2), but with ruby:2.6.8-alpine I get the error on the Ubuntu server while it still works on the WSL2 Ubuntu. That explains why it worked fine until recently: before I used the ruby:2.6-alpine label, which was updated to ruby:2.6.8-alpine recently.

Related

How to find native extension gems installed in ./vendor/bundle with "bundle doctor"

We use a Docker image to run CI builds. The Docker image has a system-installed Ruby. The Docker container has the content of gem env and bundle env as indicated in the gist linked files:
[root#045ce9939883 code]# which ruby
/usr/local/bin/ruby
[root#045ce9939883 code]# ruby -v
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]
[root#045ce9939883 code]# bundle -v
Bundler version 2.0.2
We ran the following commands in the Docker container to install the gems at ./vendor/bundle:
bundle config --local path vendor/bundle
bundle install --jobs 5 --retry 3
We then tarred the entire directory, including ./vendor/bundle so that we can deploy the contents later using capistrano. On the deployment machines, we first untarred the tar file and then ran the cap deploy commands.
bundler on the deployment machines can't seem to locate gems which are built with native extensions in ./vendor/bundle. It seems to find all the other gems just fine:
[jenkins#tel-web-sob-r01-n01 2.1.10]$ bundle doctor
The following gems are missing
* nokogiri (1.10.9)
* nio4r (2.5.2)
* websocket-driver (0.7.2)
* bindex (0.5.0)
* byebug (9.0.6)
* puma (3.9.1)
* ffi (1.9.18)
Install missing gems with `bundle install
[jenkins#tel-web-sob-r01-n01 2.1.10]$ ls -l ./vendor/bundle/ruby/2.5.0/gems/ | grep nokogiri
drwxr-xr-x 7 jenkins jenkins 157 Jun 22 13:05 nokogiri-1.10.9
The deployment machine's gem env and bundle env contents are as linked
What I know so far:
I found that all the extensions are installed in ./vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0-static/. If I rename that directory to 2.5.0, it works.
Might be related to this issue.
The Dockerfile with which we are setting up ruby & bundler is similar to this one.
The machines where we deploy the bundled gems are RHEL machines and install ruby from the software collections repositories.
It seems like the deployment machines ruby is built with the --enable-shared=yes flag.
We changed our Dockerfile to configure the ruby build the same way, ./configure --enable-shared=yes. That solved our issue.

Capistrano is installed but cap command not found

I installed capistrano vía gem install capistrano, but when I run cap install to initialize a project, that command outputs:
command not found: cap
Previously I installed ruby 2.6.5p114 with brew install ruby and updated my path to new version, this is in a MacOS version 10.14.6
I want to deploy a Symfony4 project, any idea about what step I'm missing?
Ruby Gem's may not be as consistent as the use of Composer. I use Capistrano to deploy a number of my own sites (including Symfony), and mostly followed the instructions on the capistrano-symfony page: https://github.com/capistrano/symfony/
Write the Gemfile
Install, with bundle install
Run: bundle exec cap install
Edit the capistrano config, and run with bundle exec cap prod deploy to use the configurations at config/deploy.rb & config/deploy/prod.rb

Gitlab installation - Ruby rail error

I'm using Ubuntu 16.10 and was updating my Gitlab from 6.8 to 7 and everything went wrong. Now I have removed it and is trying to install a new version but ran into a problem with Ruby.
When I try install it
$ sudo apt install gitlab
I get an error after some time:
Could not find gem 'rails (>= 4.2.7.1, ~> 4.2.7)' in any of the gem sources
listed in your Gemfile.
I have tried to run
$ sudo gem install rails
but this gives me another error:
ERROR: Error installing rails:
activesupport requires Ruby version >= 2.2.2.
I don't know what to do now...
I have started all over... Removed gitlab* and postgresql. Rebooted and installed gitlab again. Now I got another error:
Could not find gem 'pg (~> 0.18.2)' in any of the gem sources listed in your Gemfile.
Tried to install pg manually:
$ sudo gem install pg
Successfully installed pg-0.20.0
But still sudo apt upgrade gives the same error: "Could not find gem 'pg'
You may be missing a hidden dependency. Try the following:
sudo apt-get install libpq-dev
I gave up! I reinstalled the Linux server with the Linux LTS version and used the Omnibus package installation..
Problem solved!

phantomjs giving version mismatch

Using
Ubuntu 16.04
Ruby 2.0.0
(gem) cucumber (1.3.20)
(gem) cucumber-rails (1.4.2)
Initially I had
Could not find an executable ["phantomjs"] on your path. (Cliver::Dependency::NotFound)
Which was fixed with https://stackoverflow.com/a/31333531/849697
And then
Could not find an executable 'phantomjs' that matched the requirements '>= 1.8.1', '< 3.0'. Found versions were {"/usr/bin/phantomjs"=>"127.0.0.1"}. (Cliver::Dependency::VersionMismatch)
Which bizarrely seems to be giving the ip address where ought to be a version.
phantomjs and phantomjs --version both give
QXcbConnection: Could not connect to display 127.0.0.1:10.0
PhantomJS has crashed. Please read the bug reporting guide at
<http://phantomjs.org/bug-reporting.html> and file a bug report.
[1] 1919 abort (core dumped) phantomjs --version
(there is no --version in the former)
By installing phantomjs directly after downloading from bitbucket, phantomjs --version works, and tests are running and passing as expected.
https://bitbucket.org/ariya/phantomjs/downloads -> download, extract the phantomjs executable file, sudo mv it to overwrite /usr/bin/phantomjs which was installed through sudo apt-get install phantomjs
edit: previously I was doing this workaround:
xvfb-run --auto-servernum bundle exec cucumber
xvfb is a display server, to install sudo apt-get install xvfb

Installing a dev version of Vagrant but bundler doesn't seem to be installing the vagrant gem from source

I am trying to get a hackable installation of vagrant working on my machine. It uses bundler, and in its Gemspec it refers to the remote "." to add itself as a gem. The bundle install command seems to be working, but the "vagrant" gem doesn't seem to appear in gem list:
alexandma#ALEXANDMA-1-MBP ~/Projects/vagrant_ (master)
bundle install | grep "vagrant "
Using vagrant 1.6.4.dev from source at .
alexandma#ALEXANDMA-1-MBP ~/Projects/vagrant_ (master)
gem list | grep -c vagrant
0
Installing a gem from a file path or Git repository with Bundler will not install an actual gem file that can be seen by the gem command. Only Bundler is aware of the gem, so you'll need to run Bundler-aware commands to use it. In this case, running bundle list will show the entire list of dependencies including the line you see from the output of bundle install (Using vagrant 1.6.4.dev from source at .). To invoke the bundled version of Vagrant, you'll need to run bundle exec vagrant.

Resources