Gitlab: gem not found - heroku

I am trying to deploy our app to Heroku and our settings in .gitlab-ci.yml looks like
staging_heroku:
stage: deploy
script:
- git remote add heroku https://heroku:$STAGING_HEROKU_KEY#git.heroku.com/staging-myapp.git
- git push -f heroku master
This is what we see in logs
Cloning repository...
Cloning into '/builds/org/project'...
Checking out 340111af as dev/feature1...
Skipping Git submodules setup
Downloading artifacts for maven-build (17234382)...
Downloading artifacts from coordinator... ok id=17234382 responseStatus=200 OK token=2YSHdANA
/bin/sh: eval: line 46: apt-get: not found
$ apt-get update -yqqq
ERROR: Job failed: exit code 127
These runners do not even have apt-get and so I can not install gem.
I even tried git command, but even that is not found. Can someone help?

You need to install ruby and ruby-dev first! (and rubygems-integration for Debian 8)
staging:
type: deploy
script:
- apt-get update -yq
- apt-get install -y ruby ruby-dev rubygems-integration
- gem install dpl
- dpl --provider=heroku --app=teeth-taroko --api-key=$HEROKU_STAGING_API_KEY
only:
- develop

Related

Faraday::Connection without adapter has been made. CICD on Gitlab

everything was going well, before this morning, I'm totally new to cicd and things like that so I write this to deploy my app to heroku
`'API deploy':
stage: deploy back
image: ruby:latest
script:
- apt-get update -qy
- apt-get install -y ruby-dev
- gem install dpl
- cd back
- dpl --provider=heroku --app=$HEROKU_BACK --api-key=$HEROKU_API_KEY --skip_cleanup
only:
refs:
- main
changes:
- back/**/*
- .gitlab-ci.yml`
And I receive this:
An attempt to run a request with a Faraday::Connection without adapter has been made. (RuntimeError)
Please set Faraday.default_adapter or provide one when initializing the connection.
I really don't know how to do it and whats going on as I say yesterday all was good.
Update: It's seems due to the current update Faraday-2.0.0
I faced the same problem today. Apparently there is some problem in the latest version of FARADAY, at the moment. I solved it this way: add manual installation of the previous version of the dependency to your .gitlab.yml, and everything will work. Have a nice day.
before_script:
- apt-get update -qy
- apt-get install -y ruby-dev
- gem install dpl
- gem install faraday -v 1.8.0
I add the step below and it works fine
- gem install faraday -v 1.8.0

How to install latest Ruby on Gitlab config for Docker

Here's how my config looks like:
deploy_hybrid:
stage: deploy
before_script:
- apt update -qq
- apt install ruby-full -qq
- gem install cocoapods
- pod repo update
However, it's always installing Ruby 2.1
WARNING: apt does not have a stable CLI interface yet. Use with
caution in scripts. The following extra packages will be installed:
libruby2.1 libtcl8.5 libtcltk-ruby libtk8.5 libxft2 libxss1 ri ruby
ruby-dev ruby2.1 ruby2.1-dev ruby2.1-doc ruby2.1-tcltk
rubygems-integration

How to apt-get install in a GitHub Actions workflow?

In the new GitHub Actions, I am trying to install a package in order to use it in one of the next steps.
name: CI
on: [push, pull_request]
jobs:
translations:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
with:
fetch-depth: 1
- name: Install xmllint
run: apt-get install libxml2-utils
# ...
However this fails with
Run apt-get install libxml2-utils
apt-get install libxml2-utils
shell: /bin/bash -e {0}
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
##[error]Process completed with exit code 100.
What's the best way to do this? Do I need to reach for Docker?
The docs say:
The Linux and macOS virtual machines both run using passwordless sudo. When you need to execute commands or install tools that require more privileges than the current user, you can use sudo without needing to provide a password.
So simply doing the following should work:
- name: Install xmllint
run: sudo apt-get install -y libxml2-utils
Please see this answer here: https://stackoverflow.com/a/73500415/2038264
cache-apt-pkgs-action can both install and cache the apt package, so your subsequent builds are fast. It is also easier to configure, just add the packages you want:
- uses: awalsh128/cache-apt-pkgs-action#latest
with:
packages: dia doxygen doxygen-doc doxygen-gui doxygen-latex graphviz mscgen
version: 1.0

CI/CD Gitlab deployment Failed - dbl command not found

The pipeline .gitlab-ci.yml code successfully works till yesterday, but today i got the error which says “dpl command not found”
the below is my .gitlab-ci.yml file
image: node:8.9.3
stages:
- job1
- test
- production
job1:
stage: job1
script: "ls -l"
test:
stage: test
script:
- npm install
production:
type: deploy
stage: production
image: ruby:latest
script:
- apt-get update -qy
- apt-get install -y ruby-dev
- gem install dpl
- dpl --provider=heroku --app=quailapp --api-key=$HEROKU_PRODUCTION_API_KEY
only:
- master
This is the log Generated,
Setting up rake (10.5.0-2) ...
Setting up libruby2.3:amd64 (2.3.3-1+deb9u2) ...
Setting up ruby2.3 (2.3.3-1+deb9u2) ...
Setting up ruby2.3-dev:amd64 (2.3.3-1+deb9u2) ...
Setting up ruby-dev:amd64 (1:2.3.3) ...
Setting up ruby (1:2.3.3) ...
Processing triggers for libc-bin (2.24-11+deb9u3) ...
$ gem install dpl
Successfully installed dpl-1.9.6
1 gem installed
$ dpl --provider=heroku --app=quailapp --api-key=$HEROKU_PRODUCTION_API_KEY
/bin/bash: line 68: dpl: command not found
ERROR: Job failed: exit code 1
please help me for finding the solution.
Same here, Issuing the command to install dpl with verbosity: gem install dpl --verbose I've been able to see something weird:
/usr/local/bundle/bin/dpl
Successfully installed dpl-1.9.6
1 gem installed
I don't know why but it is installed in a non-default path. As a workaround I've added the /usr/local/bundle/bin in $PATH environment variable issuing the following command:
export PATH=$PATH:/usr/local/bundle/bin
It works for me and my gitlab ci pipelines are now working again.
BTW, It would be great to know why it has changed suddenly...
Same problem here. I think, it's a problem in docker image. See https://github.com/docker-library/ruby/pull/209
They made some changes and broke path for gems binaries. We have to wait until they merge fix.
UPDATE:
It's already merged and their fix works for me.

GitLab CI failing due to gem load error

I have a ruby script that fails the GitLab CI build with:
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- git (LoadError)
The ruby script:
require 'git'
Here's the .gitlab-ci.yml file:
image: gitlab/gitlab-ce:latest
job1:
script:
- apt-get update && apt-get -y install ruby && apt-get install git
- gem install git
- ./script.rb
I've also tried adding a gemfile with the git gem and running:
image: gitlab/gitlab-ce:latest
job1:
script:
- apt-get update && apt-get -y install ruby && apt-get install git
- gem install bundler
- bundle install
- ./script.rb
But I get the same error
So it was quite simple.
Needed to sudo the gem install:
image: gitlab/gitlab-ce:latest
job1:
script:
- apt-get update && apt-get -y install ruby && apt-get install git
- sudo gem install git
- ./script.rb

Resources