I'm building a rails app using gitlab ci and a few issues came up.
The first was it couldn't find rake to run the tests
I installed rake on my digital ocean manually to solve this
Then it was complaining the gitlab_ci_runner is not in the sudoers list
I added gitlab ci to the sudoers list which solved that problem
Now when running bundle install it is complaining that Bundler::GemspecError: Could not read gem for every single gem unless I install them myself.
Am I missing something with the way I setup gitlab ci?
Try using the 'gitlab_ci_runner' w/o switching user.
sudo -u gitlab_ci_runner -H bundle install --deployment
If you're root user that has a password (meaning your NOT using a SSH-Key) use this to switch back to root user.
su
Related
I have a docker image successfully built, with the following properties:
It has bundler & Ruby gems installed for a Rails project, and successfully can run that project
It runs OpenSSH, and has a user set up with a private key so that I can SSH into it. That user also has the ability to run sudo commands
When that container is up and running, if I run this command:
docker exec -it CONTAINER_ID /bin/sh, then I am dropped into the console where I can successfully execute commands like bundle exec rails console in the project root directory.
However, if I SSH in, even if I become the root user (i.e. sudo su - root), then running that command gives me this error:
Traceback (most recent call last):
2: from /usr/local/bin/bundle:23:in `<main>'
1: from /usr/local/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
/usr/local/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': Could not find 'bundler' (2.2.7) required by your /app/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.2.7`
It's as if it can't find any of the installed libraries, even though I can validate that they are present. I can also validate that when I use the docker exec... command, I gain access as the root user.
I'm going in circles trying to figure out why I'm observing such a difference in behavior. Any thoughts would be greatly appreciated.
The error you are receiving is generated since the exec can not find the bundler binary, or it finds a binary that is older version. In both cases, since you know that you have correct bundler installed, the problem will be in the PATH that is set. It's hard to tell what exactly is going on that is changing the PATH, but one thing to check is the initialization files for bash and sh.
To fix the problem, check the PATH environment variable (easiest check is echo $PATH) in both cases, and if required, set it up to the location of the bundler as follows:
In the session where it works, execute
~# which bundler
/usr/local/some_folder/bin/bundler
and in the session where you need it
export PATH=$PATH:/usr/local/some_folder/bin
You can add this to your .bashrc or .profile initialization files for the user in ssh and the root.
The other comment put me on the correct path. I ended up having to manually set these ENV vars to get things to work correctly.
export PATH=$PATH:/usr/local/bundle/bin
export BUNDLE_APP_CONFIG=/usr/local/bundle
export GEM_HOME=/usr/local/bundle
So I am trying to deploy a Rails app on my web hosting service. I have developed an app locally, but this is the first time I have tried to get it to work on another server. My service provider is Blue Host and I am on their most basic shared hosting plan. Just as a test, I created a fresh application on the server, and everything ran fine. However, whenever I add any gem to the Gemfile and run 'bundle install', I get this error:
sudo: unable to stat /etc/sudoers: No such file or directory
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
Gem::Exception: Cannot load gem at [/usr/lib64/ruby/gems/1.9.3/cache/rake-10.4.2.gem] in /home/user/application
An error occurred while installing rake (10.4.2), and Bundler cannot continue.
Make sure that `gem install rake -v '10.4.2'` succeeds before bundling.
Whenever I run gem install rake -v '10.4.2' the gem installs fine.
I get similar errors that mention 'sudo' when i try to run other commands as well.
I am not quite sure what this error means. Do I not have the required permissions on my server?
Always use a continuous deployment/integration.
Capistrano does part of the job. It is very simple, you develop you application offline, push to a remote repository, like BitBucket or Github, and then Capistrano takes care of cloning the remote repository to your server (you can also have many), restarting services etc.
If you want to go a step forward you can use continuous integration, so when you push to remote tests will automatically be performed and if they pass your application will be deployed.
This is a basic introduction on how deployment works, you can check online, there are plenty of resources about how to deploy rails.
Go with root user
su root
root$ /etc/
I am trying to setup gitlab for my team on a Ubuntu 14.04 system, my network is behind a proxy and hence facing hell lot of issue during the setup.
I was able to successfully complete most of the setup and struck at this particular command
$ sudo -u git -H bundle install --deployment --without development test mysql aws kerberos
When I run above command I get the following error
Fetching source index from https://rubygems.org/
Could not fetch specs from https://rubygems.org/
From my understanding the above error is due to proxy.
If execute below command it works perfectly alright(my current user is user1)
$ sudo bundle install --deployment --without development test mysql aws kerberos
Also, I have set all the proxy configurations by exporting http_proxy and https_proxy variables.
One more thing I would like to add is, if I execute the command for user1 it again gives the same error as above
$ sudo -u user1 -H bundle install --deployment --without development test mysql aws kerberos
I could not identify where the exact problem is.
I was following the gitlab configuration from this path
As written in the documentation
Since an installation from source is a lot of work and error prone we
strongly recommend the fast and reliable Omnibus package installation
(deb/rpm)
If you have other issues in using Gitlab, create an issue at their issue tracker.
I'm attempting to deploy a Rails app which I have developed on Windows, to Openshift. However, the bundle is not complete, because Gemfile.lock contains lines like:
pg (0.17.0-x86-mingw32)
which therefore don't get installed on the Linux instance at Openshift.
Knowing that Heroku works around this by detecting a Windows Gemfile.lock and removing it, I have tried adding a `.openshift/action_hooks/pre_build script doing either
rm Gemfile.lock
or
sed -i /mingw32/d Gemfile.lock
But neither helps. How can I deploy my app to Openshift and have it pick up suitable Linux versions of all gems?
Try including a full path to the file, like this: rm $OPENSHIFT_REPO_DIR/Gemfile.lock
You should be able to connect to the server via rhc ssh in order to test the solution.
I am building a digital ocean VPS server via ubuntu and I am having issues with my bundler. I have had this issue before on the local machine but I have no idea how to fix this issue. To be as specific as possible, I ran:
bundle install
in my application folder. It gives me the "Don't run bundle as root" message and I am not sure how to NOT run it as root here. On the local machine, I run:
sudo bundle install
to run as root and on the VPS server I am not using that sudo but it still runs as root=(
Does anyone know what I have to do to get bundler working on the VPS server? Thanks a ton for any advice!
So the answer is pretty easy, you are working as root so you need to create some user first.