How to build a gem from rails source code? - ruby-on-rails

I want to make a gem from rails source code and install the gem.
After clone the master repository of rails, I tried as follow.
$>gem build rails.gemspec
$>gem install rails-4.2.0.alpha.gem
It did not work. I also tried $>rake install which did not work either.
Looking forward your help!

There is a script in the root directory which builds from source and installs the gems. It's called install.rb. You can use it by running the following:
ruby install.rb 4.2.0.alpha
Note: At the time of writing this the arel gem needs to be built from source and installed separately before running the install script above. This is because the version constraints in rails are requiring a version of arel which has not yet been released onto rubygems.org.

Related

svn_wc gem can not be imported

I have a Ruby on Rails app, our development environment is set on macOS. I need a connection to the svn server that I use for storing files and so on.
The core problem I am facing is, despite I succeed all of the steps from the docs I can not import svn_wc gem in my controller.rb
Terminal output when I run rails serve is similar to this one
LoadError (cannot load such file -- svn/core)
I have this line in my Gemfile
gem 'svn_wc'
And had installed MacPorts for downloading Ruby bindings with the following command
sudo port install subversion-rubybindings
The gem seems buggy and does not declare dependencies correctly. It requires svn/core, which is not present in the gem source code.
The gemspec does not declare any dependency either.
However, if you read the README, you'll see that you need SVN SWIG ruby binding (whatever that is) but also ruby 1.8.
Your best bet would be to find another gem, or even use something like git-svn and interact with it like git

Bring Rails gem locally

I am working on a Rails 4 application and one of the requirements is to have all of the Gems that normally go into the Gemfile brought in locally to the machine for use. This includes Rails and after looking at many google search results I am not able to find anyone talking about using the Rails gem locally on a Rails project.
My train of thought here is to clone the rails project from Github locally and then using the bundler config path to target that directory for rails, but I am not sure how well will that solution work or even if it will work.
I will appreciate any input here or if anyone has experience with this situation I will appreciate any insight.
The bundle install does that ?
If you want to install any gem to your project go to the project root on cmd
$ gem install gemname
Doing that you locally installed the gem afterwards you want to make sure its loaded to your project so you can run
$ bundle install
And simply like that your gem is installed. Hope that helps
If you have your project on github, then you can clone it using command.
git clone github-repository-url
And then from that project directory, run command
bundle install --path vendor
It will install all your rubygems into vendor directory.

gem development (not load other Gemfile)

I've an issue with gem file development, for example I'm creating a gem with executable command.
It all works well, I can run command, BUT I've issue that if I'm trying to run command inside another project folder it's USING Gemfile from this second project.
Can I somehow disable it?
I want only to use Gemfile (and .gemspec) from my gem, and not with folder where it was executed.
I have a gem github.com/igorkasyanchuk/rails_db (version in master branch is not released yet, so you need to build it locally), gem build ..., then gem install ..., and then go to your project dir and run "railsdb". When you run it, it's trying to load gems from local folder Gemfile.
Thanks
Igor
If you are using the rubygems-bundler gem, executing commands provided by a gem will load the bundle of your current directory. You can prohibit this from happening for a particular gem providing commands in various ways. One way:
export NOEXEC_EXCLUDE=my_gem_command
See https://github.com/rvm/rubygems-bundler for more information about rubygems-bundler.

Rails Plugin - Install as Plugin or Install As Gem

I am new to rails and have a question regarding the plugins. It seems there are two approaches you can take when using a third party plugin in a ROR App:
1) install a gem using sudo gem install GEM, and then "require" it in your rails project
2) install the plugin using script/generate plugin install PLUGIN. The plugin in code appears in your vendor directory and then you are good to go (sometimes, i could not get Devise working via this method).
Since it appears both of these methods accomplish them same thing, why should I choose one method over the other.
Thanks,
Try to install the gem version of something when you can. There are a couple of benefits you get over plugins:
You can have them enabled or disabled for specific environments
You can update them via gem update. With plugins, you'd have to manually go out and update them yourself.
They are shared system wide, so if you create a new project, you can use them without having to reinstall them if you used them in a previous project. You'd have to copy/paste plugins.
Plugins are specific to rails, but gems are not. It's possible to use a gem outside of Rails.
You can still unpack gems to your vendor directory by running rake gems:unpack. This is useful to "lock in" gems to their current version, and also makes for quicker deployment since you don't have to fetch them from a 3rd party site (which is the case if you do rake gems:install).

Plugins not getting properly installed

i am having this annoying problem when deploying rails plugins. I can install them by downloading the source and putting it in the vendor/plugins directory, But i want to do it with the easy command line. I am trying to install the will_paginate plugin.
tried this command ruby script/plugin install git://github.com/mislav/will_paginate.git
that doesn't work, i tried this one as well ruby script/plugin install http://github.com/mislav/will_paginate.git
the problem i am getting is, There is no error while installing the plugin from command line, but rather there is an empty folder created inside vendor/plugins directory by the name of will_paginate, And the folder is empty. Any solutions for this?
thanks.
It sounds like you don't have git installed. Are you using Windows? If so, you'll have to download and configure a command-line git client.
If you do have git installed and configured correctly, alternatively, from your root rails directory you could try:
git clone git://github.com/mislav/will_paginate.git vendor/plugins/will_paginate
ruby script/plugin install git://github.com/mislav/will_paginate.git
That should work for you. For reference, here is the blog post from github. According to that post, this was supported beginning in Rails 2.0.2, so you'll need to be using at least that version of Rails and have git installed locally.

Resources