Rails 4.1.4, script/plugin and bin/plugin is not loading - ruby-on-rails

In rails 4.1.4, I am trying to install script/plugin install git://github.com/p8/table_builder.git plugin but I am getting an error like bash: script/plugin: No such file or directory.
Same command I have tried with bin/plugin then also I got the same error like bash: bin/plugin: No such file or directory
How can I install this plugin with the same(above) command? Please help me to solve this issue.

Firstly: p8/table_builder plugin is no longer maintained. Use this fork instead https://github.com/watu/table_builder
Secondly: You should use Gemfile to install plugins (GEMS in Ruby) and menage dependencies.
Open your Gemfile (comes with rails new by default) and add
gem "watu_table_builder", :require => "table_builder"
Save file and run bundle install (or just bundle, it's shortcut).
Bah! It's done. Dependencies are solved and gem (plugin) is installed.
Further reading: http://bundler.io/v1.3/gemfile.html

Related

When installing a gem in a local project directory, how do I figure out what the proper gem file path should be?

I'm using Ruby 2.6 and Rail 5. I want to install the following gem
$ gem install ffi -v '1.9.18' -- --with-cflags="-Wno-error=implicit-function-declaration"
Fetching ffi-1.9.18.gem
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.
but the above attempts to install it in a global location, and I would prefer to have this in my project directory, which I configured using
bundle config set --local path 'vendor/bundle'
Per the documentation, I can add this to my "gem install" command
--local path_to_gem/filename.gem
but my question is what would "path_to_gem/filename.gem" need to be to properly install this ffi gem, or can I just make something up?
Look into using RVM and taking advantage of its gemset feature. Rails projects are not like Node projects where you would have a node_modules directory where all of your dependencies live. Instead, RVM would manage your dependencies locally and keep them separate using gemsets.

Failed generating controller due to Bundler version conflict

I'm learning Rails with tutorials from Ruby on Rails by Michael Hartl: https://www.railstutorial.org/book
I used the following command to generate a controller:
rails generate controller StaticPages home help
Which generates the following error regarding version conflicts:
check_version_conflict': can't activate bundler-1.12.4, already
activated bundler-1.13.0.pre.1 (Gem::LoadError)
I don't know which bundler version to use. The current version of bundler is: 1.13.pre.1
The following command continued failing due to about five gem dependencies that failed to install automatically, which included listen and nokigiri.
bundle install --without production
I tried installing the dependent gems manually, but I'm still having issues.
How do I resolve the check_version_conflict issue with Bundler when generating Rails controllers?
I'll accept an answer that instructs removing current Ruby libs and installing a new development environment from scratch.
Bundler will install project-specific versions of your gems so that you don't have to manage global dependencies.
In effect, if you install Rails with bundler and you also install it with sudo gem install rails or something like that, you'll have two versions on your computer. By default, calling rails will refer to the global version.
If you call bundle exec rails (or bundle exec <gem_name>), it will call the bundler-specific version.
Ten steps to resolve your issues with Bundler
(optional) Uninstall Ruby. There are many ways to do so, here's one: https://superuser.com/questions/194051/how-to-completely-remove-ruby-ruby-gems-on-mac-os-x-10-6-4
(optional) Use rbenv to install Ruby. Follow instructions here: https://github.com/rbenv/rbenv
Make a repo directory that will house your future Rails app
From the command line:
mkdir repo
cd repo
Install Bundler and create a Gemfile for the directory
From the command line:
gem install bundler
bundle init
Open the repo/Gemfile with your editor, and configure it to instruct Bundler which version of Rails to install
In repo/Gemfile:
source "https://rubygems.org"
gem "rails", "4.2.6"
Install Rails via Bundler
From the command line:
bundle install
Create a new Rails app using Bundler, and cd into it
From the command line:
bundle exec rails new whatevs
cd whatevs
Your Rails app will have a Gemfile by default. Open it and add the gems you wish to use in your app.
In repo/whatevs/Gemfile:
gem 'nokogiri', '1.6.8'
From repo/whatevs/ directory, install your app's Gems via Bundler
From the command line:
bundle install
From repo/whatevs/ directory, generate a controller
From the command line:
bundle exec rails generate controller static_pages home help

Can't Install Bundler, no permissions

Im using Ubuntu 15.10. This is the code I write in the terminal
gem install bundler
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /var/lib/gems/2.1.0 directory.
Why is it trying to install it there? of course it doesn't have permissions to install it in the root directory. If I try the same command like this sudo gem install bundler it works. But it is not supposed to be installed as sudo, it gives me problems when creating a new Rails app. What should I do?
You should probably start by running gem env and look at your default environment.
You can change the default installation directory by exporting a different GEM_HOME:
export GEM_HOME=$HOME/.gem/

RVM project specific gems

I've set up an RVM environment and installed Bundler and Rake.
In my Project I've got a Gemfile, when I run bundle install the gems get installed in the project folder that I've specified. But when I run gem list I don't see the gems installed by Bundler.
Why is that?
Thanks for your help
Edit:
And also I've definied the rails gem and it's version in the project Gemfile so I never ran gem install rails
Edit 2:
I've ran gem install rails. When I run rails -v outside my project I get 3.2.12, inside my project folder I get 3.2.11 which is the version defined in my Gemfile.
But why? Why did I have to install Rails globally?
In your .rvmrc write following code:
rvm use <ruby_version>#<project_name> --create
In my case ruby_version is ruby-1.9.3-p194
Once you navigate to your project path, run bundle install to install all the gems specific to your project.

gem install trouble

I have a weird trouble, i've updated the .irbrc file to make better looking, for this I
installed awesome_print, wirble and looksee gems, check them by gem list - every gem is there.
And when i run rails console i got this:
Cannot find awesome_print gem. Please run 'gem install awesome_print' to install it.
Cannot find wirble. Please run 'gem install wirble' to install it.
Cannot find looksee. Please run 'gem install looksee' to install it.
I've no idea why it happen. I have rvm on my system but I don't think it causes the problem.
Thanks.
To install gems in Rails 3, add them to your Gemfile
For instance:
gem 'awesome_print'
gem 'wirble'
gem 'looksee'
Then run bundle install.
It's also a best practice to create a gemset with rvm per-project to isolate dependencies among projects.
To do this, in your Rails root directory run: rvm --create --rvmrc 1.9.2#myproject (substitute 1.9.2 with whatever version of Ruby you want to use).
After creating the gemset, rerun bundle install.
You'll notice an .rvmrc file has been created, which makes sure whenever you cd to that directory, the "myproject" gemset will automatically be used. Add this to version control so other developers get the same effect.

Resources