Permission denied error while installing gitlab-ci - gitlab

While installing gitlab ci (continues integration) on ubuntu (12.04LTS) i get the following error in step 5 (Setup application)
from: https://github.com/gitlabhq/gitlab-ci/blob/master/doc/installation.md
root#s2:~# cd /home/gitlab_ci/gitlab-ci/
root#s2:/home/gitlab_ci/gitlab-ci# sudo -u gitlab_ci -H gem install bundler
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /usr/local/lib/ruby/gems/1.9.1 directory.
It seems these gems try to install outside /home/gitlab_ci which indeed would fail as user gitlab_ci
My question is - are these instructions wrong? - or - am i an edge case.
And offcourse how would I safely solve this problem, just running the command as root might give me more trouble later on...
Extra information, Ruby was originally installed for gitlab itself and that works fine.

Considering that gitlab installation step 2 proposes to recompile ruby, I usually compile it with a --prefix=/home/gitlab/ruby1.9.3 argument, in order to use a ruby in which I have full rights to write/add any gem I want without using sudo.
So the $PATH used by the gitlab_ci account should include /home/gitlab/ruby1.9.3/bin and any gem installed by that account would go into the local compiled ruby.
If both accounts are part of the same group, they should both be able to write into /home/gitlab/ruby1.9.3/lib/ruby/gems/1.9.1.

Related

Team City "minimal build agent" Docker image - "npm: not found" Linux issue?

First of all, I think this is more of a Linux issue as the problem seems to be on a linux-flavoured Docker container, but I'm happy to accept that I can do something to the team city config to overcome this.
I'm also not very experienced with Linux, Docker or node/npm, though I do have a lot of development experience and am very comfortable with command line interfaces in general.
Background
We currently have Team City set up as a build server, for building a variety of projects:
.Net Framework,
.Net Core
Angular CLI
A couple of simple websites which use node packages to generate HTML from Markdown.
The server is running as a Docker container using Docker for Windows on a Windows Server box, and this is working well.
We have one Windows 10 Build agent (a VM) which is also working fine, and builds all the .Net and .Net Core stuff fine.
The simple docs site stuff primarily uses the markdown-to-html node package, so its build steps simply get all the source .md files and compile to html with markdown-to-html, plus use some other npm packages for SASS compilation and minification of js etc. No actual node code as such, just some jQuery. In order to not tie up the other agent, and because this stuff can run happily on Linux, I want to have this running on a small docker image rather than a full VM build agent somewhere.
I previously successfully used a node.js team city agent docker image (either jacobpeddk/teamcity-agent-nodejs or omez/teamcity-agent-nodejs - can't recall) which did work for a time, though I had issues with being able to install some npm packages globally in build scripts, which meant I had to get a bash terminal into the container and run some manual npm commands. I also I think had to run apt-get install zip to get a zipping step to work. This worked fine for a while (weeks).
I added some extra JS stuff to one of these simple projects, and suddenly I was getting errors when trying to build. I (perhaps stupidly) decided that this was probably due to the container having older versions of node and/or npm etc, so I attempted to update this by getting a bash shell into the container, installing nvm and updating node.js & npm.
This ended up with a rather broken container (node errors), so I thought I'd instead start again, but actually start with the jetbrains/minimal-build-agent Docker image instead, with the aim of ending up with a nice bespoke image for our needs specifically (as I couldn't find a very up-to-date pre-existing one)
I've running a Bash shell directly on the build agent container by executing this on the host:
docker exec -it basicagent /bin/bash
then from there I've installed nvm, Python (required for node install step) and node:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
apt-get update
apt-get install python 3.6
nvm install v8.11.1 (matching version on my dev machine)
npm install -g markdown-folder-to-html (npm package I previously found I had to install globally)
apt-get install zip (just used for a build step to zip up artifacts)
If I now run (via the bash shell) npm -version I get back 5.6.
If I try to get a build to run that uses npm in a command line step, then I get this error in the build log:
/opt/buildagent/temp/agentTmp/custom_script2764770419520852926: npm: not found
I wondered if it was an issue with the user/path that the team city agent process is using vs. the one I'm using in Bash, so I added the following to the build script:
echo PATH = $PATH
echo user var = $USER
echo user via 'id':
id -u -n
the output of which is:
PATH = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
user var =
user via id:
root
So it's running the agent as root, and doesn't appear to have node in the $PATH at all.
If I run the above directly from Bash however, I can see that I am root, but my $PATH is different:
PATH = /root/.nvm/versions/node/v8.11.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
root
So I'm now confused: I've re-started the container and this has had no effect - it seems that when I'm logged in as root manually I have a certain path set, but when the build agent service is running as root it's different.
I have no idea why this happens, but I've basically worked around the problem by adding:
export PATH=$PATH:/root/.nvm/versions/node/v8.11.1/bin
to the top of every build step that uses npm in a script. To my mind this seems a rather daft thing to have to do - considering this used to work without this, and the only real difference is possibly a slightly different flavour of linux container. AFAIK the original build agent container was based on the jetbrains minimal-build-agent one, so unless they've changed what they base that on it should be roughly the same...
I also had to change the compressor being used in a node-minify build step from gcc (google closure compiler) to babel-minify as the former was basically hanging indefinitely, but that is a separate problem (though also something that was fine and now isn't...)
Thanks to anyone who took the time to read... though I do wonder if one-day I'll exhaust my own research options, and finally go ask the internet and actually get someone respond - for some reason whenever I get to the point where I have to ask, it always seems no-one else has the answer either and I end up having to work it out myself. It's probably character-building though I suppose.. (this isn't just SO - I've found this be the case for over 15 years on various forums about various things...)

Puppet can't use config set server

I've installed Puppet (version 4.10.1) via Ruby Gems.
I then use:
sudo puppet config set server mysite.org
Which returns the following error (same error without sudo).
Error: No such file or directory # rb_sysopen -
/etc/puppetlabs/puppet/puppet.conf Error: Try 'puppet
help config set' for usage
The gem install does not create the configuration files, the packages will.
Puppet is best installed with a package for the operating system you're on, rather than the gem.
The steps for installing are documented here:
https://docs.puppet.com/puppet/4.10/install_linux.html
If you're feeling lazy, I even wrote a script that will do all the work for you!
https://github.com/petems/puppet-install-shell
I'm not 100% sure what led to the situation of the /etc/puppetlabs/puppet folder not being created during the install process.
I found creating the folder manually with sudo mkdir /etc/pupppetlabs/puppet before running sudo puppet config set server mysite.org fixed the issue.

Install Git on CentOS 7 LEMP stack

After about 6+ days and numerous rounds of spin-up/destroy I have FINALLY gotten my Digital Ocean droplet server up and running (ie I can view a live page of content at my ip).
At this point I am trying to install Git, and have installed/removed it 3 times so far as I keep getting 'close' to completion but then run into some error I can't find an answer for. I'm hoping someone can help me figure out what my latest problem is so I can move forward with the actual development of my site rathe than spending over a week on the server build.
I have attempted to install version 2.6.2 of git on my server and have had to compile from source (something I am no where near familiar with). I 'thought' I had it correct this time, but received the following error when I attempted to set my git user name:
gitconfig --global user.name "MyUserName" (<--- last command I made)
bash: gitconfig: command not found (<-- error i received)
I thought it was an issue with being in the wrong directory to run the command, so i ran which git and received the following output:
/usr/local/git/bin/git
This seems to be a binary (?) file and none of the directories listed in that path allow me to use gitconfig command either.
Any ideas what I have done wrong? Do I need to remove (again!) and re-compile. I don't desire to be a server admin, but really had thought (hoped?) spinning my own LEMP server on CentOS 7 would be simple - doing so on CentOS 6.* was.
Thanks for your help/advice.
gitconfig isn't a command.
You'd do:
git config --global user.name "MyUserName"
Also you're really better off installing git via yum, rather than compiling from source unless there's a good reason to compile it yourself.
(Edit - updated answer with tested solution on Centos 7).

Can't run Chef as root

I've recently returned to Linux after a 2-year hiatus. I'm trying to
learn Chef in order to automate some application deployments. In the Chef tutorial, it states that sudo is required to run a command that installs a package, which makes sense.
webserver.rb
package 'httpd'
shell command
sudo chef-apply webserver.rb
Tutorial excerpt:
sudo is required because this command installs a package and therefore must be run with root privileges. If you're running as root on your own machine, you can omit sudo from the command.
I googled the issue I was having and found a "solution" that didn't work, along with an SO question that stated you shouldn't run Chef as root. I'm not sure if I buy it.
First of all, chef is not intended to be run as root. A lot of resources assume they're run as root, and need it. They will fail if not running as root.
He also states that you should use sudo, which conflicts with his previous statement.
use sudo to run chef client with a test user (need an entry in sudoers file)
I think that he meant to say that you shouldn't run Chef as root 100% of the time. I am failing to run Chef as root, which seems to be the opposite of what the OP was trying to solve.
The error I am getting
/opt/rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb:298:in `to_specs': Could not find 'chef' (>= 0) among 13 total gem(s) (Gem::LoadError)
from /opt/rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb:309:in `to_spec'
from /opt/rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_gem.rb:53:in `gem'
from /opt/rvm/gems/ruby-2.1.5/bin/chef-apply:22:in `<main>'
from /opt/rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `eval'
from /opt/rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `<main>'
If the tutorial says that you CAN run Chef as root, and root is required to execute certain recipes, then I would think that Chef should run as root in certain cases.
My biggest question is how do I fix this error and run Chef as root? It runs fine as any other user, but fails when I try to sudo.
Well rvm reset worked after all.
So the "solution" post that I mocked earlier was actually the solution I was looking for. Karma.
DO NOT INSTALL CHEF BY GEM. (plenty of good reason too long to explain, but trust me, use omnibus package)
What happened here is that your rvm has override the path search order and the ruby call, thus the chef launcher was searching in the rvm path and not in the embedded ruby chef path. Calling rvm reset fix the problem by removing the override/path addition.
For the 'to be or not to be root' part, my answer on the question you linked had a typo. The not was forget after a rewording, (the remaining of the sentence made clear root is needed I hope). Thanks for the head up anyway.
Chef is mean to be run as root, but it's highly discouraged to connect remotely to a machine as root.
So you should use sudo to launch chef-client with root permissions 100% of time. Chef will fail on some operations if run as a normal user as it is intended to manage a whole system.
Note: I say 'should' and not 'must' as someone can probably find an edge case where it's advisable to run chef in a limited environment, but I really think it's an edge case and maybe chef is not the correct tool in this case.

Can't run heroku or vagrant in cygwin, but OK in cmd

Somehow, I can't run vagrant or heroku in cygwin. It works fine when I'm using the default windows cmd application, but in cygwin, I get this error for vagrant:
C:/vagrant/vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in to_specs': Could not find vagrant (>= 0) amongst [] (Gem::LoadError) from C:/vagrant/vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:into_spec' from C:/vagrant/vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems.rb:1231:in gem' from C:/vagrant/vagrant/embedded/gems/bin/vagrant:22:in'
And for heroku:
C:\Program Files (x86)\ruby-1.9.2\bin\ruby.exe: No such file or directory -- /cygdrive/c/Program Files (x86)/Heroku/bin/heroku (LoadError)
What is this thing about ruby? I have no idea what I should be doing - developing in windows is a real pain, can anyone provide any insight into how I might solve this problem?
Appreciate any help. Thanks!
I ran in the same problem using Rails and Heroku on Windows.
It seems that the Toolbelt is not supported under Cygwin. Moreover colors are not always rendered in the right way (for example, I did not manage to render heroku logs colors, even after using ansicon -i).
I also considered using the CMD Prompt augmented with GOW but that means you have to append ".bat" to every command, and colors are still a problem.
I ended up using the Git Bash shell that is included with the RailsInstaller package.
It recongnizes all paths to relevant files, it has all the shell commands you need, and every color seems to be rendered correctly (e.g. rails logs, cucumber and rspec tests, heroku logs, etc.).
You've probably solved your issue a long time ago but I just wanted to add the steps I went through as I had the same issue on Windows with Cygwin.
Firstly always try to do an update of your Cygwin installation especially when you see an error similar to the one you've posted (I had the same error):
/ruby: No such file or directoryin/heroku: line 4: /cygdrive/d/Development/Heroku/ruby-1.9.2/bin
So I updated Cygwin and made sure to select all necessary ruby packages/interpreters etc, but this still didn't solve the problem as I kept getting the same error message.
Then I followed the steps outlined in Running the Heroku Command-Line Client Under Cygwin:
(1) Download RubyGem 1.9.3 from
http://rubyforge.org/frs/download.php/76072/rubygems-1.8.24.zip
(2) Then run the following -
$ unzip rubygems-1.8.24.zip
$ cd rubygems-1.8.24/rubygems-1.8.24
$ ruby setup.rb install
$ gem update --system
$ gem install heroku
(3) Open a new shell window and verify the version -
$ heroku version
heroku-gem/2.28.10 (i386-cygwin) ruby/1.8.7
This solved my problem and I can now run heroku commands from the Cygwin shell on Windows.
For me #Azkuma's answer only got me half the way. What worked for me:
1) Download and extract RubyGem zip: https://rubygems.org/pages/download
2) Set aliases to gem and heroku
alias gem='C:/ruby/bin/gem'
alias heroku='"C:/Program Files (x86)/Heroku/bin/heroku.bat"'
3) install as above
ruby setup.rb install
gem update --system
gem install heroku
4) login to heroku
heroku login
I found simply setting an alias worked for me.
alias heroku=c:/Program\\\ Files\\\ \\\(x86\\\)/Heroku/bin/heroku.bat
Then I can just use the heroku command directly with Cygwin.
The only thing I have a problem with is heroku login (and by extension, git push heroku master) whereby I'm prompted to use cmd.exe. For that part, I just open my Git Bash window from within the relevant folder, login and push from there.

Resources