I ran "gem sources -c" so that I have to deliberately specify where I want to install a gem from since I now have 3 different sources for gem installs - RubyForge, Github and Gemcutter.
C:\>gem sources -c
*** Removed specs cache ***
*** Removed user source cache ***
*** Removed latest user source cache ***
*** Removed system source cache ***
*** Removed latest system source cache ***
After running this command I again ran gem sources to make sure I no longer have any default sources and I get this:
C:\>gem sources
*** CURRENT SOURCES ***
http://gems.rubyforge.org
http://gems.github.com
http://gems.rubyforge.org/
http://gemcutter.org
In other words, nothing has changed.
Looking at the help for gem sources -c below it seems to be the correct command to remove all gem sources at once:
-c, --clear-all Remove all sources (clear the cache)
Otherwise, it seems you have to remove them one by one. Not a big deal since I only have 4 but I wonder what I actually deleted by doing "gem sources -c".
C:\>gem sources --help
Usage: gem sources [options]
Options:
-a, --add SOURCE_URI Add source
-l, --list List sources
-r, --remove SOURCE_URI Remove source
-c, --clear-all Remove all sources (clear the cache)
-u, --update Update source cache
Local/Remote Options:
-p, --[no-]http-proxy [URL] Use HTTP proxy for remote operations
Common Options:
-h, --help Get help on this command
-V, --[no-]verbose Set the verbose level of output
-q, --quiet Silence commands
--config-file FILE Use this config file instead of default
--backtrace Show stack backtrace on errors
--debug Turn on Ruby debugging
For each source rubygems keeps local caches of information about gems hosted at each source etc to speed up operations and that command just clears those caches.
Looking at the rubygems source, on my system it for example removes
C:/Users/Kris/.gem/specs
C:/Users/Kris/.gem/source_cache
C:/Users/Kris/.gem/latest_source_cache
C:/Ruby/lib/ruby/gems/1.8/source_cache
C:/Ruby/lib/ruby/gems/1.8/latest_source_cache
You'll still have to remove the actual sources yourself.
Related
I've installed Ruby and Rails, and for the most part it's installed. However, when I try to create an app to see if all the installations work, the rails server won't run. It goes something like this:
I created a new rails app file, it's shown in my C: directory so that's a success
but the last line at the installation said this:
bundle install
The latest bundler is 2.3.10, but you are currently running 1.15.3.
To update, run `gem install bundler`
Fetching source index from https://rubygems.org/"
I tried the
gem install bundler
next, but I got this error message:
ERROR: Could not find a valid gem 'bundler' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=error: certificate verify failed (https://api.rubygems.org/specs.4.8.gz)
also when I tried,
rails s
I got this result:
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: C:/RailsInstaller/Ruby2.3.3/bin/ruby.exe
-m, [--template=TEMPLATE] # Path to some application template (can be a filesystem path or URL)
-d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/postgresql/sqlite3/oracle/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
# Default: sqlite3
[--skip-yarn], [--no-skip-yarn] # Don't use Yarn for managing JavaScript dependencies
[--skip-gemfile], [--no-skip-gemfile] # Don't create a Gemfile
-G, [--skip-git], [--no-skip-git] # Skip .gitignore file
[--skip-keeps], [--no-skip-keeps] # Skip source control .keep files
-M, [--skip-action-mailer], [--no-skip-action-mailer] # Skip Action Mailer files
-O, [--skip-active-record], [--no-skip-active-record] # Skip Active Record files
-P, [--skip-puma], [--no-skip-puma] # Skip Puma related files
-C, [--skip-action-cable], [--no-skip-action-cable] # Skip Action Cable files
-S, [--skip-sprockets], [--no-skip-sprockets] # Skip Sprockets files
[--skip-spring], [--no-skip-spring] # Don't install Spring application preloader
[--skip-listen], [--no-skip-listen] # Don't generate configuration that depends on the listen gem
[--skip-coffee], [--no-skip-coffee] # Don't use CoffeeScript
-J, [--skip-javascript], [--no-skip-javascript] # Skip JavaScript files
[--skip-turbolinks], [--no-skip-turbolinks] # Skip turbolinks gem
-T, [--skip-test], [--no-skip-test] # Skip test files
[--skip-system-test], [--no-skip-system-test] # Skip system test files
[--dev], [--no-dev] # Setup the application with Gemfile pointing to your Rails checkout
[--edge], [--no-edge] # Setup the application with Gemfile pointing to Rails repository
[--rc=RC] # Path to file containing extra configuration options for rails command
[--no-rc], [--no-no-rc] # Skip loading of extra configuration options from .railsrc file
[--api], [--no-api] # Preconfigure smaller stack for API only apps
-B, [--skip-bundle], [--no-skip-bundle] # Don't run bundle install
[--webpack=WEBPACK] # Preconfigure for app-like JavaScript with Webpack (options: react/vue/angular)
Runtime options:
-f, [--force] # Overwrite files that already exist
-p, [--pretend], [--no-pretend] # Run but do not make any changes
-q, [--quiet], [--no-quiet] # Suppress status output
-s, [--skip], [--no-skip] # Skip files that already exist
Rails options:
-h, [--help], [--no-help] # Show this help message and quit
-v, [--version], [--no-version] # Show Rails version number and quit
Description:
The 'rails new' command creates a new Rails application with a default
directory structure and configuration at the path you specify.
You can specify extra command-line arguments to be used every time
'rails new' runs in the .railsrc configuration file in your home directory.
Note that the arguments specified in the .railsrc file don't affect the
defaults values shown above in this help message.
Example:rails new ~/Code/Ruby/weblog
This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
I have tried to install bundler, update bundler, update system... none of that worked. I've also tried the cacert.pem file for certification (according to one of the tutorial articles I found), but it's still doesn't work.
I'm using Windows 10, ruby 2.3.3p222 and Rails 5.1.3. With this, do I need to reinstall Ruby and Rails? Is there something missing in my installation?
When I build a project with gcc, I can use the very useful -I flag to specify additional include dirs. Sometimes, gems require code to be compiled, but I can't use the -I flag. Specifically, I can't build RMagick on my machine because it fails on the MagickWand step:
checking for wand/MagickWand.h... no
I know exactly where MagickWand.h is. How do I tell gem where to find it?
UPDATE:
I have two versions of ImageMagick on my system (for work) and gem throws this error:
Warning: Found more than one ImageMagick installation. This could cause problems at runtime.
/a/Magick-config reports version 6.5.8 Q8 is installed in [a]
/b/Magick-config reports version 6.6.4 Q16 is installed in [b]
Using 6.5.8 Q8 from [a].
gem is using version [a] whereas I want it to use version [b]...but I can't find any way to have it switch to [b]. As far as I can tell, gem doesn't consult my $PATH.
The guides indicate that like you can pass build options
If an extension fails to compile during gem installation the gem specification is not written out, but the gem remains unpacked in the repository. You may need to specify the path to the library’s headers and libraries to continue. You can do this by adding a – between RubyGems’ options and the extension’s build options:
$ gem install some_extension_gem
[build fails]
Gem files will remain installed in /path/to/gems/some_extension_gem-1.0 for inspection.
Results logged to /path/to/gems/some_extension_gem-1.0/gem_make.out
$ gem install some_extension_gem -- --with-extension-lib=/path/to/lib
[build succeeds]
$ gem list some_extension_gem
*** LOCAL GEMS ***
some_extension_gem (1.0)
$
For you, that sounds like gem install rmagick -- -I /path/to/MagickWand.h but I'm not really sure how to try it out to verify.
while installing any Gem or doing any listing of gem gzip related error comes as shown below:-
C:\Documents and Settings\gangunra>gem install rhosync -v 2.0.0.beta7 --pre
ERROR: While executing gem ... (Zlib::GzipFile::Error)
not in gzip format
C:\Documents and Settings\gangunra>gem list rails -r
*** REMOTE GEMS ***
ERROR: While executing gem ... (Zlib::GzipFile::Error)
not in gzip format
Please help me out how to reslove this
Looks like rubygems.org (or any gem source you have defined) is down.
Not sure if your error was happening in tar_input.rb or ruby_core_source.rb.
Most people solved tar_input.rb error, by cleaning up cache files. I solved the one for ruby_core_source.rb:57 'initialize' : not in gzip format
and here is the description and workaround:
The problem was because "sometimes" the ruby source file in the ftp server is not probably tar + gzip. So sometimes the source file is incorrect.
I just gone through the source code, and the code expects a .tar.gz in the ftp server (e.g. http ://ftp.ruby-lang.org/pub/ruby/1.9/xxx.tar.gz). But the file found was only tar, but not gzip-ed.
The workaround is to modify the code in your gem directory.
I am looking for ppl who knows why the file hosted in ruby-lang.org is not properly gzip-ed. Hope that can solve forever.
Here is the detail description of my finding:
http://ru05team.blogspot.com/2011/08/solving-workaround-initialize-not-in.html
Here is the workaround, source code that you have to change:
https://gist.github.com/1183048
Make sure you are using the right Gem sources.
$ gem sources
should display http://rubygems.org/ as the first source.
If missing, add http://rubygems.org/ as the main source. Otherwise, it might be a temporary issue with RubyGems index.
Also make sure you are using the latest RubyGems (library) version.
$ gem update --system
Find out where your ruby is configured to look for sources:
C:\>gem sources
*** CURRENT SOURCES ***
http://gems.rubyforge.org/
If it is pointed at gems.rubyforge.org (which it is when first installed for older installation binaries) then you’re pointed at the old web server so when ruby tries to get updates it gets an HTTP redirect (302) as a response instead of the expected data in GZIP format. It apparently doesn’t have an error handler configured to detect the redirect so it just gives up.
To fix it you have to update the list of sources. First add the correct source:
C:\>gem sources -a http://rubygems.org/
http://rubygems.org/ added to sources
Then remove the deprecated one:
C:\>gem sources -r http://gems.rubyforge.org/
http://gems.rubyforge.org/ removed from sources
C:\>gem sources
*** CURRENT SOURCES ***
http://rubygems.org/
Next update your ruby system:
C:\>gem update --system
Updating RubyGems
Updating rubygems-update
Successfully installed rubygems-update-1.3.7
:0:Warning: Gem::SourceIndex#search support for String patterns is deprecated
Updating RubyGems to 1.3.7
Installing RubyGems 1.3.7
RubyGems 1.3.7 installed
=== 1.3.7 / 2010-05-13
NOTE:
http://rubygems.org is now the default source for downloading gems.
You may have sources set via ~/.gemrc, so you should replace
http://gems.rubyforge.org with http://rubygems.org
http://gems.rubyforge.org will continue to work for the forseeable future.
...
Note that update verifies that the old source URL is no longer valid…
You should now be able to continue your installation, which in my case was rake.
I ran into this problem when using a network that requires phase 2 authentication. I had forgotten to authenticate in the browser so any web request was redirected to a local authentication page. It would appear that gem does not check whether the response it receives is actually from the actual rubygems.org server (and it's can't based on the address lookup alone unless you used an ssl certificate). Rather than telling you it couldn't reach the real rubygems server, it simply tells you the payload it receives is not in the proper format (zipped). Presumable if you ran a malicious DNS server that redirected rubygems.org to your own service, you could inject anything you wanted into the gems....
I read a answer the gem fetch answer on this question is-it-possible-to-download-a-ruby-gem-without-installing-it-automatically. But windows I do not always get the windows gem.
Using gem install gosu --remote installs the windows version Successfully installed gosu-0.7.15-x86-mswin32-60.
When downloading using gem fetch gosu I get Downloaded gosu-0.7.15 which is the linux version and can not be installed on my windows PC.
Asking for the specific gem with gem fetch gosu-0.7.15-x86-mswin32-60 and similar tries yields ERROR: Could not find gosu-0.7.15-x86-mswin32-60 in any repository
Any ideas as to how to get the correct version for my PC when using fetch versus install?
$ gem fetch --help
Usage: gem fetch GEMNAME [GEMNAME ...] [options]
Options:
-v, --version VERSION Specify version of gem to fetch
--platform PLATFORM Specify the platform of gem to fetch
Local/Remote Options:
-B, --bulk-threshold COUNT Threshold for switching to bulk
synchronization (default 1000)
-p, --[no-]http-proxy [URL] Use HTTP proxy for remote operations
--source URL Use URL as the remote source for gems
Common Options:
-h, --help Get help on this command
-V, --[no-]verbose Set the verbose level of output
-q, --quiet Silence commands
--config-file FILE Use this config file instead of default
--backtrace Show stack backtrace on errors
--debug Turn on Ruby debugging
Arguments:
GEMNAME name of gem to download
Summary:
Download a gem and place it in the current directory
Defaults:
--version '>= 0'
You should be able to do
$ gem fetch gosu --platform x86-mswin32
Or simply go to the download page.
I have added gemcutter.org to my Rubygems sources, and now I do not know how to remove it.
$ gem sources
*** CURRENT SOURCES ***
http://gemcutter.org
http://gems.rubyforge.org/
$ gem sources -r http://gemcutter.org
http://gemcutter.org removed from sources
$ gem sources
*** CURRENT SOURCES ***
http://gems.rubyforge.org/
In general you can find the syntax with
gem help *command*
So this shows the options you needed:
gem help sources
But what if the problem is that the default source causes gem install to hang on non-connected systems? (You think it's impossible?!?) If you run the command provided by the most popular answer, and this happens:
# gem sources -r https://rubygems.org
source https://rubygems.org not present in cache
Then to deal with this situation, you must modify source cringe:
sed -i '/[[:space:]]def self\.default_sources/a return []' \
$RUBYGEMS_DIR/rubygems/defaults.rb
This adds a line of code, namely return [] to return an empty array, after the method that returns "default sources". Run gem environment and you will see no nasty remote sources. Now you can go back and undo the sed command, or manually add the rubygems repo or whatever.
EDIT: Clarify, generalize.