What is the best way to test RailsApps App in Gitlab CI? - ruby-on-rails

I've created Ruby on Rails app using Rails Composer and I want to use it with Gitlab CI (v5.0.1 on OS X 10.9.4) with Gitlab CI Runner also on OS X 10.9.4.
What I should use as build steps? I started with:
. ~/.bash_profile
rvm use ruby-2.1.2#myapp
bundle install
rspec spec
I used .bash_profile because rvm doesn't work without it. Is there better way?
I found that some files are not in Git (like database.yml and application.yml). What is the best way to add them back or how to setup them in Gitlab CI?
EDIT:
I've added back default database.yml as database.example.yml. Now, I use these build steps:
. ~/.bash_profile
cp config/application.example.yml config/application.yml
cp config/database.example.yml config/database.yml
rvm use ruby-2.1.2#myapp
bundle install
rspec spec

Related

"rails new" is not generating any of my project's folders

I have downloaded Ruby, and installed the rails gem, then I attempt to run rails new my-project and all I get is this:
c:\Projects>rails new my-project
create
create README.md
create Rakefile
create .ruby-version
create config.ru
create .gitignore
create Gemfile
run git init from "."
When I open the my-project folder that rails created for me what I find in it is only:
.gitignore
.ruby-version
config.ru
Gemfile
Rakefile
README.md
and nothing else.
This is not what I got when testing this at home, and it's not what any guide says I should get. I have exactly zero folders generated by rails, it's nowhere near what I need to start development. I don't think I'm missing any installations. Here are the versions of ruby and of rails:
c:\Projects>ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x64-mingw32]
c:\Projects>rails -v
Rails 6.0.2
IIRC I installed Ruby using the Windows Ruby Installer at rubyinstaller.org, the latest version with Devkit, then I simply ran gem install rails to get Rails.
The only thing I can think of is that my user does not have admin privileges in this computer, but when I try to Google if this is a requirement, all Google gives me is how to implement admin stuff in my app.
Try appending --skip-git to your rails new command. This will get you going in the short term.
Alternatively (and probably the better option in the long run), install git. The official Git documentation install instructions can be found here: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
I have the same issue. Thanks to Scott Schupbach answer I realize that I didn't Install git, because I was working in a fresh ubuntu 19.10 installation.
So for anyone with the same issue, just install git.
In Ubuntu (or other Debian-based Linux distribution) just type:
sudo apt install git
On Mac (using Homebrew):
brew install git
For Windows, non-Debian Linux systems, and alternative Mac installer options, see the official Git installation documentation: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
And that's all.
Best Regards!!
uninstall rails
delete the project folder
install git with sudo - "sudo apt install git"
reinstall rails - "gem install rails"
create the project folder again and do the cd command to be in the new folder
Run the command again- "rails new [project name]"
Facing this issue as git was not installed on system.
Try to run below command to install git
sudo apt install git
And then create a new rails project with rails command
rails new myApp
It will create complete folder structure for you

'bundle is not installed' error

I am not good with devops. I had created a user called deploy. Previously I could ssh into my server then
su deploy
and run
RAILS_ENV=production bundle exec rails c
.
Some days ago, I completely forgot that I had a user called deploy. Being the root user, I installed ruby using rvm. RVM was already installed.
Now I remember that I have a user called deploy. I ran su deploy then ran
RAILS_ENV=production bundle exec rails c
I got the following error
The program 'bundle' is currently not installed. To run 'bundle'
please ask your administrator to install the package 'ruby-bundler'
Before I had installed ruby in super admin env I could run bundle in the deploy user env.
Is there a way to fix this?
PS: My capistrano deployment script is running without any problem even if it is being deployed by the "deploy" user
The problem is that when you ssh into the directory, at the directory, no .ruby-version file exists, so it use the default ruby version(run which ruby to see the exactly path), not the rvm ruby version, so it can't find the installed gems like bundler.
It's a environment problem.The capistrano deployment is working because you have assign ruby version in your deploy.rb like
set :rvm_ruby_version, 'ruby-2.2.2#zhitaotao'
so it can find correct ruby version, then find installed gems for the version.
The solution is add a file called .ruby-version, set the content to something like ruby-2.3.1.
If this not works, i suggest to reinstall ruby, bundler, and run bundle install for deploy user. We need to make sure that at the production directory, the ruby version is matched with the ruby version assigned in the deploy.rb.

How to clone and run another user's Rails app

I'm attempting to do something I've never done before: clone another user's (codeforamerica) repository and run it locally on my computer with the intention of making my own changes to it.
I've managed to fork it to my own repositories, and cloned it:
git clone https://github.com/martynbiz/human_services_finder.git
...but when I do the following straight out the box:
cd human_services_finder
rails s
...it tell me:
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
...however, if I go into one of my own apps and run rails s it runs the server OK. Is there something missing I need to run this as a Rails app? Sorry, bit of a beginner with this one. Thanks
Below are the setups to run Ruby on Rails application on your system.
Make sure Ruby is installed on your system. Fire command prompt and run command:
ruby -v
Make sure Rails is installed
rails -v
If you see Ruby and Rails version then you are good to start, other wise Setup Ruby On Rails on Ubuntu
Once done, Now
Clone respected git repository
git clone https://github.com/martynbiz/human_services_finder.git
Install all dependencies
bundle install
Create db and migrate schema
rake db:create
rake db:migrate
Now run your application
rails s
You need to install all the dependencies (Gems). This should be possible by running
bundle install
from the applciations directory.
If you are not using RVM yet I would strongly recommend doing so.

Gitlab CI can't install gem

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

Redmine Icalendar export issue in mac

I am facing some issues when try to install following plugin in mac os.
It is working fine in linux as well as in windows.
https://github.com/thegcat/redmine_ical
Steps I followed:
After copying plugin files in vendor/plugin folder. Redmine stops working and shows "We're sorry but something went wrong" error message.
I am using bitnami-redmine-1.4.7-2-osx-x86_64-installer.dmg and when I remove Gemfile and require dispatcher from init.rb It starts running but doesn't show Ical on calendar page.
After copying plugin file we need to run "bundle install" command from terminal.
In bitnami stack redmine after copying plugin file,
1) $cd install dir
2) $./use_redmine
3) $bash: cd root_dir
4) bundle install
This will work .
The accepted answer didn't work for me, but did help me one step.
I had to do the following to make it work succesfully:
cd installdir/apps/redmine/htdocs
bundle install --without development test postgresql sqlite --no-deployment
bundle install --without development test postgresql sqlite --deployment
ruby bin/rake redmine:plugins RAILS_ENV=production
This all in addition to (or actually from within) using the "use_redmine" bash from the install dir.
I've opted to go for the other ical plugin, that didn't require the patchfiles (https://github.com/buschmais/redmics)
https://docs.bitnami.com/installer/apps/redmine/#how-to-install-the-redmine-agile-plugin

Resources