What's the proper way to install rails after cloning from github? - ruby-on-rails

I cloned rails 4 from github and want to install rails from the local repo. What's the best way to do the installation? I ran install.rb starting from a fresh gemset but it failed because of missing gems. Anyone know a post that walks through this? Should I do the install from the remote github repo first and then run the install.rb file?
Also, just want to be clear here. I am not trying to just install using gem install or using :git in my gem file. Please do not put those instructions in your comments. I absolutely want to install from a local clone, as a first step toward fixing Rails when I encounter bugs not fixed.

Bundle the local gem.
gem "rails", :path => "~/your/rails/checkout"
gem "activerecord", :path => "~/your/rails/checkout"
etc...

Related

Contributing to Gem - gem not updating

I'm trying to add a small bug fix to an open source gem. Here's what I've done:
cloned the repository to local
made changes and saved
changed gemfile of rails project to point to local version of gem
> gem 'gem_name', path: "/Users/admin/gem_name"
> bundle install
> bundle update gem_name
> rails s
The gem doesn't reflect any changes I've made (gem isn't updated). I had to change the version.rb file and then run bundle update gem_name to see changes. But to my understanding, this shouldn't be required to see changes?
Why don't you fork the gem in github? fix what you want and then point that for your github link... If you think your fix could be great for another users, why not a pull request? ;)
gem 'gem_name', :git => 'https://github.com/my_user/gem.git'

What is the most easy way to install gem?

I need to uninstall a gem "rubyzip 1.1.0" and install the older version "rubyzip 0.9.9"
I need to enter in a specific folder in ssh to do this?
I need upload some file to sftp or I can do a command with some url?
If there is a very simple way even I am very grateful.
Take a look at your Gemfile and look for the line gem 'rubyzip'.
Change this line to: gem 'rubyzip', '0.9.9'
Now run bundle install from your application root directory to fetch and install the downgraded gem (and all of its dependencies).
Done.

How do I add a local custom gem with RVM or otherwise?

I have to add a custom gem which is downloaded onto my local machine. How do I get it installed with Rails? I also have RVM installed. I tried pasting it into the gems folder but it doesn't get installed.
I believe to install a gem you need to run the setup.rb file but this gem doesn't seem to have that present. Any pointers to how to get this gem installed?
It's very important because I think this gem has dependencies and is stopping my project from running.
Another option, in addition to #shingara's, is you can still add it to your Gemfile, but it will depend on everyone in your project team having the gem in the same location. Then you can do:
gem 'my_gem', '0.1.2.3', :path => '~/my_projects/my_gem_folder/'
And when you bundle, it'll pull and install from there.
If you're working on something by yourself, you can do this without worry that someone else who pulls down that project won't have that gem in the same location.
EDIT In addition to your comment for #shingara's answer, this works for not pointing straight to a .gem file, but to a folder that your gem resides in.
You can install a gem by this path
gem install path/my_gem.gem

Branch of a Gem is not installed correctly with Rails and Gemfile

Initial Problem
I was using yaml_db in a Rails project, but it seems the default branch has some issues with boolean records. Now I know that there's a branch on github that has a fixed version.
I changed my Gemfile so that this branch will be installed instead of the default yaml_db,
gem 'yaml_db', :git => "https://github.com/robsharp/yaml_db.git"
I run bundle install and it shows:
Using yaml_db (0.2.0) from https://github.com/robsharp/yaml_db.git (at master).
Your bundle is complete! It was installed into /Users/user/.rvm/gems/ruby-1.9.2-p0
Fine. Now the fixed file in the Git repository should have this line in lib/serialization_helper.rb:
record[column] = convert_boolean(record[column])
Yet, when I look at my local file, which is .rvm/gems/ruby-1.9.2-p0/bundler/gems/yaml_db-ca178cfb59cf/lib/serialization_helper.rb, it still shows the unpatched old line:
record[column] = (record[column] == 't' or record[column] == '1')
Fine, seems as my local file isn't changed.
Gem not being installed correctly
Running gem list won't show me yaml_db at all. I removed the Gem lockfile and installed the bundle again, still there is no yaml_db in my Gem listing. Running gem install yaml_db of course only installs the broken version.
Manual Install
I now try to manually install from the Git source.
git clone https://github.com/robsharp/yaml_db.git
cd yaml_db
git checkout -b fix_boolean_checks_to_support_oracle
Still, the serialization_helper.rb file is not updated correctly. I just manually changed it and built the Gem. Everything works fine now.
My new question: Why won't it check out the correct file?
If you run gem list yaml_db and see multiple versions in parenthesis, define the version you need in your Gemfile like so
gem 'yaml_db', '~> 0.2.0', :git => "https://github.com/robsharp/yaml_db.git"
I had a similar problem and found out that the Gemfile.lock file stored my old and not–updated version and used that for my project.

rails gem programming - How do I try it before pushing to gemcutter?

I'm developing a new gem (fork of nifty-generators).
Right now my "deployment" consists on the following:
I make changes on the gem's source code
I commit to github
I update the gemspec lower numer (i.e. go from 0.1.1 to 0.1.2)
Build the gem and push it to gemcutter (gem build, gem push)
Install the new gem (sudo gem install mygem)
Then y try the new gem.
I'm sure there must be a more correct way of doing things. Right now, I'm uploading to gemcutter so that I can test my gem.. and that doesn't feel right.
What is the best way to "test your gem before uploading to gemcutter"?
Once you have your gemspec, you can run gem build yourgem.gemspec. That will produce a .gem file for you to install....try the following commands out to verify it:
gem install --local
gem spec
gem unpack
You have to push a built gem to RubyGems.org anyway, so you're pretty much there :)
if you're using jeweler, try this
rake install
(rake --tasks will tell you more)
launch all test unit or rspec test.
You can try in our project after install it on your system.

Resources