Posts

Showing posts with the label Rails

Redmine - 500 error when upload files

For couple years, users could not upload files into our Redmine instance when creating or updating issues (or tickets). We ignored it because most of the tickets were created from the email pulling task (IMAP) and the attachments were created just fine. But when we developed an external tool to manipulate issues with attachment, I think it's time to seriously looking at the problem and fix it. Here is the command we try (upload file using Redmine's Rest API): # curl 'http://myredmine.com/uploads.json' -X POST -H 'X-Redmine-API-Key: <myapikey>' -H 'Content-Type: application/octet-stream' --data-binary "@myfile.png" and errors (/var/log/redmine/default/production.log): ... Completed 500 Internal Server Error in 15.4ms Errno::EACCES (Permission denied - /var/lib/redmine/default/files/2016/12):   app/models/attachment.rb:108:in `files_to_final_location'   app/controllers/attachments_controller.rb:88:in `upload' ... Rea...

Cannot push code to gitlab after upgraded to v7.8 from v6.9 and how to fix

After we upgraded our gitlab server to v7.8 from v6.9 , we could not push code to it and always got this error: ... remote: /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.8.3/lib/bundler/shared_helpers.rb:2:in `require': no such file to load -- rubygems (LoadError) remote:         from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.8.3/lib/bundler/shared_helpers.rb:2 remote:         from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.8.3/lib/bundler/setup.rb:1:in `require' remote:         from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.8.3/lib/bundler/setup.rb:1 To http://our.repo.url/myusername/my-project.git  ! [remote rejected] my_branch -> my_branch (pre-receive hook declined) ... I was trying to re-compile ruby 2.1 so many times but had no luck. After messing around, I finally fixed this issue by: 1. Remove and Purge all ruby binaries except for ruby 2.1 from my server: sudo apt-get remove rub...

Could not run rails console in gitlab due to missing readline

Yesterday, I was trying to open the rails console of my gitlab server (gitlab v6.9.2, Ubuntu 12.04) to reset the admin password by the following command: $ cd /home/git/gitlab $ sudo -u git -H bundle exec rails console production But it raised this error: ... `require': no such file to load -- readline (LoadError) ... After a while, I fixed it by ( DO NOT MODIFY THE GEMFILE ): 1. Install readline dev packages: $ sudo apt-get install libreadline-dev 2. Recompile or upgrade ruby to v2.1: Note: The use of Ruby version managers such as RVM, rbenv or chruby with GitLab in production frequently leads to hard to diagnose problems. For example, GitLab Shell is called from OpenSSH and having a version manager can prevent pushing and pulling over SSH. Version managers are not supported and we strongly advise everyone to follow the instructions below to use a system Ruby. Install the required packages to compile ruby: $ sudo apt-get install -y build-essential zlib1g-de...

Setup GEM_HOME for your ruby gems installation in Ubuntu

I found this setup is pretty helpful when working with Rails projects in Ubuntu (it's 14.04 in this case): Add these lines at the end of ~/.bashrc : export GEM_HOME=$HOME/ruby/gems export GEM_PATH=$GEM_HOME:/lib/ruby/gems/1.9.3 export GEM_CACHE=$GEM_HOME/cache export PATH=$PATH:$HOME/ruby/gems/bin To get affected right away: $ source ~/.bashrc