Can't add sources with gem - ruby

I'm trying to add http://rubygems.org/ in my sources because I can't use 'gem install NAME' (this error : Could not find a valid gem 'dashing' (>= 0) in any repository).
So, I did this command : gem sources -a http://rubygems.org/
the result : ERROR: While executing gem ... (Gem::OperationNotSupportedError)
Not connected to a tty and no default specified
I give you my ENV :
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.5.1
- RUBY VERSION: 2.2.4 (2015-12-16 patchlevel 230) [i386-mingw32]
- INSTALLATION DIRECTORY: C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0
- RUBY EXECUTABLE: C:/RailsInstaller/Ruby2.2.0/bin/ruby.exe
- EXECUTABLE DIRECTORY: C:/RailsInstaller/Ruby2.2.0/bin
- SPEC CACHE DIRECTORY: C:/Users/mramart/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: C:/ProgramData
- RUBYGEMS PLATFORMS:
- ruby
- x86-mingw32
- GEM PATHS:
- C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0
- C:/Users/mramart/.gem/ruby/2.2.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- :sources => []
- REMOTE SOURCES:
- SHELL PATH:
- C:\Users\mramart\bin
- C:\Program Files (x86)\Git\mingw32\bin
- C:\Program Files (x86)\Git\usr\local\bin
- C:\Program Files (x86)\Git\usr\bin
- C:\Program Files (x86)\Git\usr\bin
- C:\Program Files (x86)\Git\mingw32\bin
- C:\Program Files (x86)\Git\usr\bin
- C:\Users\mramart\bin
- C:\RailsInstaller\Git\cmd
- C:\RailsInstaller\Ruby2.2.0\bin
- C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
- C:\Tcl\bin
- C:\ProgramData\Oracle\Java\javapath
- C:\WINDOWS\system32
- C:\WINDOWS
- C:\WINDOWS\System32\Wbem
- C:\WINDOWS\System32\WindowsPowerShell\v1.0
- C:\WINDOWS\System32\WindowsPowerShell\v1.0
- C:\Program Files (x86)\Lenovo\Access Connections
- C:\Program Files\nodejs
- C:\Program Files\Java\jdk1.7.0_79\bin
- C:\Program Files (x86)\Heroku\bin
- C:\Program Files (x86)\git\cmd
- C:\Program Files\TortoiseSVN\bin
- C:\Program Files\PostgreSQL\9.5\bin
- C:\Program Files (x86)\scala\bin
- D:\gatling-charts-highcharts-bundle-2.1.7\bin
- C:\Program Files (x86)\sbt\bin
- %USERPROFILE%\.dnx\bin
- C:\Program Files\Microsoft DNX\Dnvm
- C:\Program Files\Microsoft SQL Server\130\Tools\Binn
- C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit
- C:\Users\mramart\AppData\Roaming\npm
- C:\Program Files\Java\jdk1.8.0_73\bin
- C:\apache-maven-3.0.5\bin
- C:\Program Files\PostgreSQL\9.5\bin
- C:\Program Files\MongoDB\Server\3.2\bin
- D:\liquid
- C:\Users\mramart\AppData\Local\atom\bin
- C:\Program Files (x86)\Git\usr\bin\vendor_perl
- C:\Program Files (x86)\Git\usr\bin\core_perl
None sources executing : gem sources

In such cases, I directly make changes to my Gem Config file. Here is an updated version of ~/.gemrc:
---
:backtrace: false
:bulk_threshold: 1000
:sources:
- http://rubygems.org
:update_sources: true
:verbose: true
Here's how to verify:
$ gem sources
http://rubygems.org/

Related

Ruby on rails installation puma error on Windows

I tried to install the puma because when I tried bundle, it said I need to install the puma, but when I tried to install it, I got this error
gem install puma -v '3.12.6' --source 'https://rubygems.org/'
Temporarily enhancing PATH to include DevKit...
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing puma:
ERROR: Failed to build gem native extension.
current directory: C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/puma-3.12.6/ext/puma_http11
C:/Ruby26-x64/bin/ruby.exe -I C:/Ruby26-x64/lib/ruby/site_ruby/2.6.0 -r ./siteconf20210202-20756-30084d.rb extconf.rb
checking for BIO_read() in -lcrypto... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/Ruby26-x64/bin/$(RUBY_BASE_NAME)
--with-puma_http11-dir
--without-puma_http11-dir
--with-puma_http11-include
--without-puma_http11-include=${puma_http11-dir}/include
--with-puma_http11-lib
--without-puma_http11-lib=${puma_http11-dir}/lib
--with-openssl-dir
--without-openssl-dir
--with-openssl-include
--without-openssl-include=${openssl-dir}/include
--with-openssl-lib
--without-openssl-lib=${openssl-dir}/lib
--with-cryptolib
--without-cryptolib
C:/Ruby26-x64/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from C:/Ruby26-x64/lib/ruby/2.6.0/mkmf.rb:552:in `try_link0'
from C:/Ruby26-x64/lib/ruby/2.6.0/mkmf.rb:570:in `try_link'
from C:/Ruby26-x64/lib/ruby/2.6.0/mkmf.rb:782:in `try_func'
from C:/Ruby26-x64/lib/ruby/2.6.0/mkmf.rb:1016:in `block in have_library'
from C:/Ruby26-x64/lib/ruby/2.6.0/mkmf.rb:959:in `block in checking_for'
from C:/Ruby26-x64/lib/ruby/2.6.0/mkmf.rb:361:in `block (2 levels) in postpone'
from C:/Ruby26-x64/lib/ruby/2.6.0/mkmf.rb:331:in `open'
from C:/Ruby26-x64/lib/ruby/2.6.0/mkmf.rb:361:in `block in postpone'
from C:/Ruby26-x64/lib/ruby/2.6.0/mkmf.rb:331:in `open'
from C:/Ruby26-x64/lib/ruby/2.6.0/mkmf.rb:357:in `postpone'
from C:/Ruby26-x64/lib/ruby/2.6.0/mkmf.rb:958:in `checking_for'
from C:/Ruby26-x64/lib/ruby/2.6.0/mkmf.rb:1011:in `have_library'
from extconf.rb:8:in `block in <main>'
from extconf.rb:8:in `each'
from extconf.rb:8:in `find'
from extconf.rb:8:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
C:/Ruby26-x64/lib/ruby/gems/2.6.0/extensions/x64-mingw32/2.6.0/puma-3.12.6/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/puma-3.12.6 for inspection.
Results logged to C:/Ruby26-x64/lib/ruby/gems/2.6.0/extensions/x64-mingw32/2.6.0/puma-3.12.6/gem_make.out
This is the mkmg.log file. I thought it is because I didn't' download the devkit so I downloaded the dev kit and I did ruby dk.rb init, dk.rb install --force but it doesn't work.
"x86_64-w64-mingw32-gcc -o conftest.exe -IC:/Ruby26-x64/include/ruby-2.6.0/x64-mingw32 -IC:/Ruby26-x64/include/ruby-2.6.0/ruby/backward -IC:/Ruby26-x64/include/ruby-2.6.0 -I. -D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0600 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64 -O3 -fno-fast-math conftest.c -L. -LC:/Ruby26-x64/lib -L. -pipe -s -lx64-msvcrt-ruby260 -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char **argv)
6: {
7: return 0;
8: }
/* end */
My gem env outputs are
RubyGems Environment:
- RUBYGEMS VERSION: 3.2.7
- RUBY VERSION: 2.6.3 (2019-04-16 patchlevel 62) [x64-mingw32]
- INSTALLATION DIRECTORY: C:/Ruby26-x64/lib/ruby/gems/2.6.0
- USER INSTALLATION DIRECTORY: C:/Users/Kim/.gem/ruby/2.6.0
- RUBY EXECUTABLE: C:/Ruby26-x64/bin/ruby.exe
- GIT EXECUTABLE: C:\Program Files\Git\cmd/git.EXE
- EXECUTABLE DIRECTORY: C:/Ruby26-x64/bin
- SPEC CACHE DIRECTORY: C:/Users/Kim/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: C:/ProgramData
- RUBYGEMS PLATFORMS:
- ruby
- x64-mingw32
- GEM PATHS:
- C:/Ruby26-x64/lib/ruby/gems/2.6.0
- C:/Users/Kim/.gem/ruby/2.6.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- c:\program files\graphicsmagick-1.3.35-q16
- C:\Program Files\Microsoft MPI\Bin\
- C:\Program Files (x86)\Common Files\Oracle\Java\javapath
- C:\Windows\system32
- C:\Windows
- C:\Windows\System32\Wbem
- C:\Windows\System32\WindowsPowerShell\v1.0\
- C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
- C:\Program Files\Intel\WiFi\bin\
- C:\Program Files\Common Files\Intel\WirelessCommon\
- C:\WINDOWS\system32
- C:\WINDOWS
- C:\WINDOWS\System32\Wbem
- C:\WINDOWS\System32\WindowsPowerShell\v1.0\
- C:\WINDOWS\System32\OpenSSH\
- C:\Program Files\Java\jdk-10.0.2\bin
- C:\Users\Kim\Desktop\mysql-8.0.16-winx64\mysql-8.0.16-winx64\bin
- C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR
- C:\WINDOWS\system32
- C:\WINDOWS
- C:\WINDOWS\System32\Wbem
- C:\WINDOWS\System32\WindowsPowerShell\v1.0\
- C:\WINDOWS\System32\OpenSSH\
- C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\
- C:\Program Files (x86)\Microsoft SQL Server\150\Tools\Binn\
- C:\Program Files\Microsoft SQL Server\150\Tools\Binn\
- C:\Program Files\Microsoft SQL Server\150\DTS\Binn\
- C:\Program Files\Microsoft SQL Server\130\Tools\Binn\
- C:\Program Files (x86)\Brackets\command
- C:\Program Files\dotnet\
- C:\Program Files\Git\cmd
- C:\Program Files (x86)\dotnet\
- C:\Program Files\CMake\bin
- C:\Program Files\PostgreSQL\13\lib
- C:\Program Files\PostgreSQL\13\bin
- C:\Program Files\GraphicsMagick-1.3.35-Q16
- C:\MinGW\bin
- C:\Ruby26-x64\devkit\bin
- C:\msys64\mingw64\bin
- C:\msys64\mingw64\lib
- C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin
- C:\Ruby26-x64\devkit\mingw\bin
- C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0
- C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\lib\gcc\i686-w64-mingw32\8.1.0\include\c++\tr1
- C:\Ruby26-x64\bin
- C:\Users\Kim\AppData\Local\Programs\Microsoft VS Code\bin
- C:\Users\Kim\AppData\Local\Microsoft\WindowsApps
- C:\Users\\.dotnet\tools
- C:\Users\Kim\AppData\Local\GitHubDesktop\bin
- C:\Program Files (x86)\GitHub CLI\

Have Twurl installed, but I can't access it

I have installed Twurl but for some reason I still can't use it. I believe I have it installed because it shows up when I type the ls command. Then I am able to navigate to the folder that Twurl is contained in. However, I am not able to go into the Twurl folder because it says it is not a directory. I am able to use the command open twurl, which opens up a seperate terminal window with a lot of information about Twurl, but I can't type anything. One other thing, when I try and run twurl authorize I get this response: twurl: command not found So my question is, how do I go about getting twurl to work now? Such that I can run the twurl authorize command.
gem env output:
- RUBYGEMS VERSION: 3.1.4
- RUBY VERSION: 2.7.2 (2020-10-01 patchlevel 137) [x86_64-darwin18]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.7.0
- USER INSTALLATION DIRECTORY: /Users/CharlieBagin/.gem/ruby/2.7.0
- RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /usr/local/lib/ruby/gems/2.7.0/bin
- SPEC CACHE DIRECTORY: /Users/CharlieBagin/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/2.7.2/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-18
- GEM PATHS:
- /usr/local/lib/ruby/gems/2.7.0
- /Users/CharlieBagin/.gem/ruby/2.7.0
- /usr/local/Cellar/ruby/2.7.2/lib/ruby/gems/2.7.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/opt/ruby/bin
- /Users/CharlieBagin/anaconda3/bin
- /Library/Frameworks/Python.framework/Versions/3.6/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
I think I might have installed it in two places. I originally used gem install twurl, but then it wasn't working and I was trying some things and used bundler to install at some point too.

How to alter RubyGems Environment Variables (USER INSTALLATION DIRECTORY and SPEC CACHE DIRECTORY)

When trying to install a gem i receive an error:
No such device or address # rb_file_s_stat - Z:/
when checking the gem environment variables i get the following return:
C:\Program Files (x86)\SOME_FOLDER\Ruby\bin>gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 2.6.6
- RUBY VERSION: 2.3.1 (2016-04-26 patchlevel 112) [x64-mingw32]
- INSTALLATION DIRECTORY: C:/Program Files (x86)/SOME_FOLDER/Ruby/lib/ruby/gems/2.3.0
- USER INSTALLATION DIRECTORY: Z:/.gem/ruby/2.3.0
- RUBY EXECUTABLE: "C:/Program Files (x86)/SOME_FOLDER/Ruby/bin/ruby.exe"
- EXECUTABLE DIRECTORY: C:/Program Files (x86)/SOME_FOLDER/Ruby/bin
- SPEC CACHE DIRECTORY: Z:/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: C:/ProgramData
- RUBYGEMS PLATFORMS:
- ruby
- x64-mingw32
- GEM PATHS:
- C:/Program Files (x86)/SOME_FOLDER/Ruby/lib/ruby/gems/2.3.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- C:\Program Files (x86)\Common Files\Oracle\Java\javapath
- C:\Windows\system32
- C:\Windows
- C:\Windows\System32\Wbem
- C:\Windows\System32\WindowsPowerShell\v1.0\
- C:\Windows\System32\OpenSSH\
- C:\Program Files\TortoiseSVN\bin
- C:\Users\rekenmt\AppData\Local\Microsoft\WindowsApps
the problem is clear: USER INSTALLATION DIRECTORY and SPEC CACHE DIRECTORY are not valid paths (Z:/ disk does not exist.) the question therefore is:
how do i change those variables to point to another path
Thank you in advance
I had the same issue and running this in the command line fixed it for me.
SET HOME=%USERPROFILE%
Source here: https://github.com/oneclick/rubyinstaller/wiki/Troubleshooting#gem-commands-fails-if-home-maps-to-a-network-drive

Permission denied, when installing a new gem

I am in Windows 7, I can see that all my gems are in :
C:\Users\alotfi2.gem\specs\api.rubygems.org%443\quick\Marshal.4.8
Last week we received an email from the admin that said :
After migration, your H: drive will be read-only. This means you'll be able to access and transfer your files but you won't be able to edit them or save any new files to your H: drive.
but when I tried to install a new gem I got :
gem install chronic
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # rb_sysopen - H:/.gem/specs/api.rubygems.org%443/quick/Marshal.4.8/chronic-0.10.2.gemspec
gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 2.3.0
- RUBY VERSION: 2.4.2 (2017-09-14 patchlevel 198) [x64-mingw32]
- INSTALLATION DIRECTORY: C:/Ruby24-x64/lib/ruby/gems/2.4.0
- RUBY EXECUTABLE: C:/Ruby24-x64/bin/ruby.exe
- EXECUTABLE DIRECTORY: C:/Ruby24-x64/bin
- SPEC CACHE DIRECTORY: H:/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: C:/ProgramData
- RUBYGEMS PLATFORMS:
- ruby
- x64-mingw32
- GEM PATHS:
- C:/Ruby24-x64/lib/ruby/gems/2.4.0
- H:/.gem/ruby/2.4.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- C:\majid\cmder\bin
- C:\majid\cmder\vendor\git-for-windows\cmd
- C:\majid\cmder\vendor\conemu-maximus5\ConEmu\Scripts
- C:\majid\cmder\vendor\conemu-maximus5
- C:\majid\cmder\vendor\conemu-maximus5\ConEmu
- C:\Program Files (x86)\Shoes
- C:\Ruby24-x64\bin
- C:\Users\alotfi2\AppData\Local\Programs\Python\Python36-32\Scripts\
- C:\Users\alotfi2\AppData\Local\Programs\Python\Python36-32\
- C:\Users\alotfi2\AppData\Roaming\npm
- C:\Program Files\Docker Toolbox
- C:\majid\cmder\vendor\git-for-windows\usr\bin
- C:\majid\cmder\vendor\git-for-windows\usr\share\vim\vim74
- C:\majid\cmder\
your help is appreciated .
Thanks.
Your SPEC CACHE DIRECTORY still links to your H: drive, to change its value, you have to set environment variable GEM_SPEC_CACHE as stated in this thread.
To do so on Windows, you would want to use SetX command. For example:
SETX GEM_SPEC_CACHE C:\Users\User\.gem\abc
You should have writing access rights to directory C:\Users\User\.gem\abc for it to work.

<RubyGems> How to change gem environment settings?

I installed rbenv and set up ruby and gems. Now if I run gem env then I got the following:
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.2
- RUBY VERSION: 2.1.0 (2013-12-25 patchlevel 0) [x86_64-darwin13.0]
- INSTALLATION DIRECTORY: /Users/myusername/Tools/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0
- RUBY EXECUTABLE: /Users/myusername/Tools/.rbenv/versions/2.1.0/bin/ruby
- EXECUTABLE DIRECTORY: /Users/myusername/Tools/.rbenv/versions/2.1.0/bin
- SPEC CACHE DIRECTORY: /Users/myusername/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-13
- GEM PATHS:
- /Users/myusername/Tools/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0
- /Users/myusername/.gem/ruby/2.1.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/myusername/Tools/.rbenv/versions/2.1.0/bin
- /Users/myusername/Tools/.rbenv/libexec
- /Users/myusername/Tools/.rbenv/plugins/ruby-build/bin
- /opt/local/bin
- /opt/local/sbin
- /Users/myusername/Tools/.rbenv/shims
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /usr/local/bin
- /Users/myusername/Tools/./bin
- /Users/myusername/Tools/.rbenv/bin
Well.. all looks good except for SPEC CACHE DIRECTORY and GEM PATHS, all others have self-configured paths. (So I really don't want any dev-related directories directly placed in my user home folder.) Is there a way to flexibly change these two env variables without affecting normal functioning of ruby, gem and rbenv etc.?
Thanks!
Actually I searched online and found the solution.
Just put the following in your .profile (Max OS) or .bashrc (Linux)
export GEM_PATH=/Users/myusername/Tools/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0
export GEM_SPEC_CACHE=/Users/myusername/Tools/.rbenv/versions/2.1.0/lib/ruby/gems/specs
Make sure the folder you put there existed. Then source the .profile or .bashrc, or simply restart your terminal. It is tested working now my env is correct.
Reference:
https://github.com/rubygems/rubygems/pull/489

Resources