Creating a new rails 3 project over a proxy in windows - ruby-on-rails

My computer works on a proxy. So in order to install gems I use the following command
gem install -p http//#{proxy-server}:#{port} rails
If i use the normal gem install command, I get an error could not find gem. I installed rails 3.1 today and tried to create a new project. Half the way while creating the files, the generator started executing run bundle install and ended up giving the same error
Fetching source index for http://rubygems.org/
Could not reach rubygems repository http://rubygems.org/
Could not find gem 'turn (>= 0, runtime)' in any of the gem sources listed in your Gemfile.
The generator is trying to install some gems without proxy. How can I override this existing functionality? I want the generator to use gem install -p http//#{proxy-server}:#{port} #{gem} instead of gem install #{gem}

Add the given option to your gemrc file
gem: -p http//#{proxy-server}:#{port}
Under unix this file is located under ~/.gemrc, for windows I don't know, but according to this answer should be
# Under windows XP
C:\Documents and Settings\All Users\Application Data\gemrc
# Under Windows Vista/Seven
C:\ProgramData\gemrc for windows Vista/Seven
The rc file needs to be created if not present.

Related

Ruby on rails 5; How to stop installing gem related files when I bundle install

I was making a chat app with ruby on rails 5.
I tried to implement image sending function in my app.
I followed the instruction of the below blog.(sorry in Japanese)
http://yamakichi.hatenablog.com/entry/2017/01/18/232856
1) bundleinstall below gems
gem "carrierwave"
gem "piet"
gem "mini_magick"
2) Create uploader
But it didn't work.
I removed gem "piet" by bundle upload after I deleted it.
At this moment, I realized that about 8000 unknown files were installed.
Below are examples of the file names installed.
vendor/bundle/ruby/2.3.0/bin/rake
vendor/bundle/ruby/2.3.0/cache/concurrent-ruby-1.0.5.gem
vendor/bundle/ruby/2.3.0/gems/concurrent-ruby-1.0.5/lib/concurrent/hash.rb
....
All the files start with "vendor/bundle/ruby/2.3.0".
If I delete this "vendor/bundle/ruby/2.3.0" file, I can remove every unnecessary files.
But next, I couldn't turn on local server.
It said,
"Could not find rake-12.1.0 in any of the sources"
"Run bundle install to install missing gems."
And if I bundleinstall, this 8000 file were installed again.
How can I avoid this problem?
The gem piet may be a dependency of another gem in your Rails project. When in doubt you can delete your copy of Gemfile.lock and run bundle again. It will auto-generate a new copy with the correct dependencies.
If you're working on a Rails project, it's totally normal for ~8,000 files to be installed since Rails itself relies on quite a few gems.
One way to cut down on the number of files installed by bundler is to skip the documentation within each gem. That can be accomplished by adding this to your local ~/.gemrc file
gem: --no-document

Empty gem list, but can use rails --version

I understand that Rails is a gem. Which means when I run
gem list
the terminal should echo the name rails for me.
My problem is that I can run
rails --version
but when it comes to gem list I only receive *LOCAL GAME LIST* without any text following.
What could be wrong? Is it my understanding?
Thank you and best regards
Check Your Path and/or Package Manager
If you have Rails installed through your package manager, rather than as a gem, then your local gem list will be empty. If you are running Debian or Ubuntu, dpkg -l rails will show you whether it's installed as a system package instead.
You can also find which binary you're invoking with which rails on the command line. If you did a source install, that may tell you where in your PATH the Rails application is located.

Rails app cant detect local gems

This is a very odd one and I'm not sure how to proceed.
Basically, I am able to install gems and use them normally within any folder except those created with rails. It's very very odd. It's difficult to explain so maybe this console output will explain
passenger#rubyserve:~/railsapps$ ls
app test_application testing
passenger#rubyserve:~/railsapps$ rails -v
Rails 3.2.2
passenger#rubyserve:~/railsapps$
passenger#rubyserve:~/railsapps$
passenger#rubyserve:~/railsapps$ cd app/
passenger#rubyserve:~/railsapps/app$ ls -a
. app config.ru doc Gemfile.lock lib public README.rdoc test vendor
.. config db Gemfile .gitignore log Rakefile script tmp
passenger#rubyserve:~/railsapps/app$
passenger#rubyserve:~/railsapps/app$
passenger#rubyserve:~/railsapps/app$ rails -v
The program 'rails' is currently not installed. To run 'rails' please ask your administrator to install the package 'rails'
passenger#rubyserve:~/railsapps/app$
It makes bugger all sense. When outside my rails folder, I can call rails to make a new application but once within, rails isn't detected. This is the same for all gems including bundler.
My first thought was that somehow, rails had some specific gem folder hidden away, so I done my gem install from within the rails project, however this didn't work either.
Any thoughts?
My setup is ubuntu server 10.10 (I know, i know)
Ruby 1.9.2
gem 1.8.17
and I'm using the latest rvm from wayneeseguin.enter code here
This type of problem some time occurs i think u can save a lot of time by installing and using RVM
After installing RVM create gemset directory every time whenever you create separate project. e.g you create application blog first you create gemset directory with giving this command
rvm gemset create blog
then you should use this gemset directory and also ruby version as well e.g you have install ruby 1.9.2 then use this command
rvm use ruby-1.9.2#blog
after that go into directory of blog application and install this gem
gem install bundler
and also then bundle install. so all local gem will be installed into this blog directory under rvm and there will be no conflicts will be appear.But keep one thing in mind if your platform is ubuntu then this will work

Error when creating new Rails project

I installed the Rails installer. Now I'm trying to create a new Rails project. When I do
C:\Sites> rails new demoproj
I get this error:
Fetching source index for http://rubygems.org/
Could not reach rubygems repository http://rubygems.org/
Could not find gem 'turn (>= 0)' in any of the gem sources listed in your Gemfile.
I'm assuming you are installing rails over proxy. This maybe what you are looking for:
Add the given option to your gemrc file
gem: -p http//#{proxy-server}:#{port}
Creating a new rails 3 project over a proxy in windows
in a general way, that problem means you need to do a bundle install. no clue if its a windows specific issue though, there should be an automatic bundle after it creates the project.

Problem installing LESS for Ruby on Rails - script/plugin: command not found

I am trying to install LESS in a Ruby on Rails project. I am able to run the gem successfully, but when I try to install the plugin for LESS, I get an error. Here's what shows in the terminal:
MacBook:benji jesse$ sudo gem install less
Successfully installed less-1.2.21
1 gem installed
Installing ri documentation for less-1.2.21...
Installing RDoc documentation for less-1.2.21...
MacBook:benji jesse$ sudo script/plugin install git://github.com/cloudhead/more.git
sudo: script/plugin: command not found
I am a .NET developer trying to learn Ruby on Rails (on a Mac), so I am new to all this stuff.
My question's are:
Is the script/plugin command a standard command?
What does it do?
Where can I learn more about this command?
Why does it say command
can't be found?
Is the script/plugin command a standard command?
It is in rails 2, it has changed in rails 3:
rails plugin
# or
script/rails plugin
What does it do?
installs the given plugin into the RAILS_ROOT/vendor/plugin, but you should look if there is a gem version of the plugin, than you can add a gem dependency to this gem.
Where can I learn more about this command?
run the command without any parameters
Why does it say command can't be found?
try ls script/ and see if the file exists.
You have to be in the application directory. Say you created your rails app in the folder development/rails_app. You must execute the script/plugin command from there (and you don't need super user permissions for that):
cd development/rails_app
script/plugin install git://github.com/cloudhead/more.git
The plugin installation will apply only to the current rails application (in this case, rails_app). So if you create another application, you must run the script/plugin command again.

Resources