rbenv install giving me a Build Failed - ruby

I am having issues getting ruby-build to work through rbenv. When I run rbenv install 2.2.2 (or any other version) I get the following output:
Downloading ruby-2.2.4.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.4.tar.bz2 Installing ruby-2.2.4...
BUILD FAILED (Ubuntu 16.04 using ruby-build 20170201-7-g5d62e84)
Inspect or clean up the working tree at /tmp/ruby-build.20170227230105.17714 Results logged to /tmp/ruby-build.20170227230105.17714.log
Last 10 log lines:
removed 'conf17793.dir/conf17793.file'
removed 'conf17793.file'
config.guess already exists
config.sub already exists
checking build system type... config.sub: too many arguments
Try `config.sub --help' for more information.
configure: error: /bin/bash tool/config.sub x86_64-pc-linux-gnu
removed '/tmp/cg1RYI8Z/dummy.c' removed '/tmp/cg1RYI8Z/dummy.o' failed
removed 'confdefs.h' removed directory '/opt/rbenv/versions/2.2.4/lib'
removed directory '/opt/rbenv/versions/2.2.4'
The full logs are not much longer but I will post them here just in case they are relevant:
/tmp/ruby-build.20170227230105.17714 /opt/rbenv
removed 'ruby-2.2.4.tar.bz2'
/tmp/ruby-build.20170227230105.17714/ruby-2.2.4 /tmp/ruby-build.20170227230105.17714 /opt/rbenv
removed 'conf17793'
removed 'conf17793.dir/conf17793.file'
removed 'conf17793.file'
config.guess already exists
config.sub already exists
checking build system type... config.sub: too many arguments
Try `config.sub --help' for more information.
configure: error: /bin/bash tool/config.sub x86_64-pc-linux-gnu
removed '/tmp/cg1RYI8Z/dummy.c'
removed '/tmp/cg1RYI8Z/dummy.o' failed
removed 'confdefs.h'
I searched online and haven't seen anyone else getting this error in relation to ruby-build or rbenv.
I will also explain my setup and how I installed rbenv just to give as much info as possible.
I am running Ubuntu 16.04 and cloned the rbenv repo to my /opt directory. sudo git clone https://github.com/rbenv/rbenv.git /opt. I added the rbenv set up lines to my .proflie file.
export RBENV_ROOT="/opt/rbenv/"
if [ -d "${RBENV_ROOT}" ]; then
export PATH="${RBENV_ROOT}/bin:${PATH}"
eval "$(rbenv init -)"
fi
I then cloned the ruby-build repo git clone https://github.com/rbenv/ruby-build.git /opt/rbenv/plugins/ruby-build
I then created a new group called ruby (that my user is in.) and recursively set it as the group for all of /opt/rbenv so now it's owned by root:ruby.
After all that rbenv appears to be working, I can run commands like rbenv versions (It shows system and 1.9.3-p0 which I installed manually) and rbenv local 1.9.3-p0. With no problem. I can also run rbenv install -l and get a full list with no problem so they both appeared to be installed properly.
If anyone can give me any ideas of what might be going wrong when I try to install a ruby version I would greatly appreciate it.

I found the problem. rbenv install downloads the ruby versions specfied then run the ./configure --prefix=/path/to/rbenv/versions/2.2.2. This is the command that was failing. After looking into one of the versions I downloaded that failed installing and going through it's configure script it was using a script called config.guess to determine the system type. This script creates some temporary files and deletes them. This would normally be fine but I have a custom rm command in my path, it does a few things but one of those things is to add the verbose flag. This was muddying the output of the config.guess script and breaking things later in the .configure script that were dependent on the output of this script. I fixed this by removing the verbose flag from my custom rm command and just placing it in a an alias.
Short answer (TLDR):
I had a custom rm command in my path that was breaking stuff.

Related

How to change pythonpath to use Python 3.9 and venv

I am trying to get to grips with Python on my Mac running OS X 10.15.7 Catalina.
My goal is to be able to run a program requiring Python 3.9 and associated libraries, in its own virtual environment, using venv.
My quest has led me over many rocky paths and blind alleys - including via Anaconda and Brew.
I am running zsh - specifically oh-my-zsh ys version. If that's important. Most online forums and tutorials assume bash. I would prefer to do all in zsh to avoid having to edit both zsh and bash profiles.
Current Shell Outputs
$ python -V
Python 2.7.16
$ which python
/usr/bin/python
$ python3 -V
Python 3.8.2
$ which python3.8
python3.8 not found
$ which python3.9
python3.9 not found
$ python3 -m -V
/Library/Developer/CommandLineTools/usr/bin/python3: No module named -V
Pausing there ..
Py 2.7 is the OS X system Python and I don't want to do anything with it.
It is odd that python3 -m returns a reference to the CLI tools. See below. The only location for py3.8 is in the CL tools.
What pythons do I have (output below is edited so as to show only main directories and Files)?
$ locate python
/Applications/LibreOffice.app/Contents/Frameworks/LibreOfficePython.framework/Versions/3.7/bin/python3
/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/bin/python3.8
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
/Library/Developer/CommandLineTools/usr/bin/python3.8
/Library/Frameworks/Python.framework/Versions/3.9/bin/python3
/Library/Frameworks/Python.framework/Versions/3.9/bin/python3-config
/Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9
/Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9-config
/Library/Frameworks/Python.framework/Versions/3.9/share/man/man1/python3.1
/Library/Frameworks/Python.framework/Versions/3.9/share/man/man1/python3.9.1
/Library/Frameworks/SAVI.framework/Versions/A/Frameworks/Python.framework/Versions/3.6/lib/python3.6
/usr/bin/python
/usr/bin/python-config
/usr/bin/python2
/usr/bin/python2.7
/usr/bin/python2.7-config
/usr/bin/python3
/usr/bin/pythonw
/usr/bin/pythonw2.7
/usr/lib/libpython.dylib
/usr/lib/libpython2.7.dylib
/usr/lib/python2.7
/usr/local/bin/python3
/usr/local/bin/python3-config
/usr/local/bin/python3.9
/usr/local/bin/python3.9-config
/usr/share/file/magic/python
/usr/share/man/man1/python.1
/usr/share/man/man1/python2.7.1
/usr/share/man/man1/pythonw.1
/usr/share/man/man1/pythonw2.7.1
/usr/share/vim/vim81/autoload/python3complete.vim
/usr/share/vim/vim81/autoload/pythoncomplete.vim
/usr/share/vim/vim81/ftplugin/python.vim
/usr/share/vim/vim81/indent/python.vim
/usr/share/vim/vim81/syntax/python.vim
/usr/share/zsh/5.7.1/functions/_bpython
/usr/share/zsh/5.7.1/functions/_python
/usr/share/zsh/5.7.1/functions/_python_modules
WHAT ABOUT PIP?
$ pip3
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
$ pip3 install --upgrade pip
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in ./Library/Python/3.8/lib/python/site-packages (20.3.3)
Note two points
Although the wrapper warning comes up, PIP 20.3.3 is latest version which I have upgraded. Probably the reason for the warning is in the next lines, which suggest that PIP3 is being invoked from the CL Tools.
2; The ‘normal site-packages is not writeable’ error is supposed to be cured by specifying the Path. I have tried already to specify the correct path - see below - but this has not cured the problem and is another major reason for asking the question at the end of this post.
$ python -m pip
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No module named pip
$ python3 -m pip
Usage:
/Library/Developer/CommandLineTools/usr/bin/python3 -m pip <command> [options]
$ which pip3
/usr/bin/pip3
$ locate pip3
/Applications/LibreOffice.app/Contents/Frameworks/LibreOfficePython.framework/Versions/3.7/bin/pip3
/Applications/LibreOffice.app/Contents/Frameworks/LibreOfficePython.framework/Versions/3.7/bin/pip3.7
/Library/Developer/CommandLineTools/usr/bin/pip3
/Library/Developer/CommandLineTools/usr/bin/pip3.8
/Library/Frameworks/Python.framework/Versions/3.9/bin/pip3
/Library/Frameworks/Python.framework/Versions/3.9/bin/pip3.9
/usr/bin/pip3
/usr/local/bin/pip3
/usr/local/bin/pip3.9
SYSTEM FILES
~/.zprofile contents - edited a few times to remove references to virfualenv and penv, both originally installed with brew and now removed. I have run brew uninstall and brew remove to try to clean everything up but may not have succeeded.
Start
# THIS FILE COMMENTED OUT RH 21DEC20
## Setting PATH for Python 3.9
## The original version is saved in .zprofile.pysave. **Note in this post only - cannot find this file**
PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:${PATH}"
export PATH **Note in this post only - this does not seem to have worked - see above Python3 -V**
# export WORKON_HOME=~/.virtualenvs
# mkdir -p $WORKON_HOME
# . ~/.pyenv/versions/3.9.0/bin/virtualenvwrapper.sh
# eval "$(pyenv init -)"
# # AND THESE LINES ADDED FOLLOWING STACKOVERFLOW Q 33216679 **Note in this post only - commented out as shell threw errors .’cannot find virtualenvwrapper.sh**
# export WORKON_HOME=$HOME/.Envs
# # export VIRTUALENVWRAPPER_PYTHON=$/usr/bin/python3
# export VIRTUALENVWRAPPER_PYTHON=$/usr/local/bin/python3
#source $HOME/.local/bin/virtualenvwrapper.sh
END
Finally a word about Brew. Many tutorials advised the use of Brew to install Python, pyenv, and libraries etc. I did that and successfully created a test environment, but could not the utilise it. I have then removed as much as possible in order to get back to a ‘clean’ state to work with.
Current brew status is
$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!
Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected dylibs:
/usr/local/lib/libdvdcss.2.dylib
/usr/local/lib/libfuse.0.dylib
/usr/local/lib/libulockmgr.0.dylib
Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected header files:
/usr/local/include/ulockmgr.h
Warning: Unbrewed .la files were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected .la files:
/usr/local/lib/libulockmgr.la
Warning: Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected static libraries:
/usr/local/lib/libfuse.a
/usr/local/lib/libulockmgr.a
SUMMARY
My first goal is to set Py3.9.x as default for new projects. I think also this would require/imply that pip and other commands run from v3.9 and not any other version or location. Must admit to being hazy about that.
Then I want to be able to create a virtual environment into which I can put the program I want to run and its associated libraries and packages. Doing this implies using terminal, but I need to know which directory I need to be in to run which commands.
At this point I have also been running into confusion with tutorials on how to create a virtual environment. From what I have read I think I should use venv over pyenv. What is not clear is whether I run the venv command (s) from root, or whether I have to create and cd to a different location, and if so what.
Any help in
1 Changing the default Python to 3.9
2 Creating a venv to use v3.9.
3 What commands to run where.
Will be greatly appreciated. Please keep it simple and don't assume any prior knowledge!
This is what I would do :
# For 1 Changing the default python to 3.9
cd /usr/local/bin
sudo ln -fs /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 python3
sudo ln -fs python3 python
# And make sure /usr/local/bin is before (/usr/bin and /Library/Developer/CommandLineTools/usr/bin) in your $PATH
# For 2 Creating a venv to use v3.9
/usr/local/bin/python3.9 -m venv /tmp/python3.9-venv

linuxbrew/lib/ld.so: bad ELF interpreter: No such file or directory

I am having a problem about linuxbrew.
bash: /lustre7/home/lustre4/user1/applications/bin/cut: /lustre7/home/lustre4/user1/.linuxbrew/lib/ld.so: bad ELF interpreter: No such file or directory
I tried to uninstall linuxbrew using instructions at its website, but somehow it didn't work (because of sudo requirements).
there is linuxbrew directory but I can't remove when I type rm -r linuxbrew it says;
-bash: /lustre7/home/lustre4/user1/applications/bin/rm: /lustre7/home/lustre4/user1/.linuxbrew/lib/ld.so: bad ELF interpreter: No such file or directory
When I tried to install homebrew it says your CPU is not supported. (I tried this before and it worked, but now it is not working.)
I want to solve this problem but I couldn't find any solution. I am not able to run sudo and yum commands because I am not root. I am a user at a linux cluster.
OK. I finally was able to solve this issue.
I am wring in case someone else may have the same issue.
First, this was related to a bash problem. I recently installed a tool that put some variables to both bashrc and bash_profile and altered path of bin directory.
I wasn't able to use system commands such as rm, ls, cat etc. and I wasn't able to run system ruby. Paths of all commands and ruby were in my bin directory under my application directory.
What I did is;
I edited my bash_profile by cancelling the new path that caused conflict between bash_profile and bashrc. This enabled me run system commands.
I uninstalled linuxbrew as described in its website.
I removed linuxbrew from my home directory, and cancelled its path in bash_profile (comment out).
I installed homebrew again and put its path to my bashrc.
Now it is working.
I could uninstall linuxbrew using the procedure I described in here:
How to completely uninstall brew and re-install brew in ubuntu 19.04
-> In short, I just replaced install.sh by uninstall.sh and it worked...
$/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"

Cannot install lektor in pyenv virtualenv: `clang' exists in these (other) Python versions

I'm trying to install lektor into a new virtualenv using pyenv virtualenv. I have no problem making a new virtualenv with Python 3.7.0, but when I try to pip install lektor, I get a build failure with watchdog and the following error message:
pyenv: clang: command not found
The `clang' command exists in these Python versions:
anaconda3-5.0.0
error: command 'clang' failed with exit status 127
I understand that the anaconda3 version has clang, but I also have a version installed in /usr/bin. The output of which -a clang is:
$PYENV_ROOT/shims/clang
/usr/bin/clang
Can I manually set the shim to point to usr/bin? Or is there a different solution to this issue?
This is a rotten solution, but it does work. By taking the shim for clang and temporarily moving it (e.g., mv $PYENV_ROOT/shims/clang ~/Desktop), watchdog can be installed, then the clang shim can be moved back to the original location. A better option would be for pyenv to default to the system versions of programs if a shim doesn't point anywhere in a given environment…
Alternative solution
The pyenv plugin pyenv-which-ext takes care of this class of issues by checking for the existence of utilities in the normal $PATH after seeing that they aren't present in the current environment. It's a quick install via Homebrew, took care of all my issues.

Homebrew Warnings: How do I resolve these warning and correct my path on Mac 10.10.2 Yosemite?

I'm fairly new to programming so I could really use your help.
I think Yosemite upgrade has royally screwed up my path and homebrew, and was hoping you folks can help me get back on track without reseting my mac. So as I get ready to dive back into rails I ran brew doctor and got a bunch of warnings, but not "ready to brew", how do I fix this?
Here is my current path:
anian$ echo $PATH
/usr/local/bin:/usr/local/rvm/gems/ruby-2.0.0-p353/bin:/usr/local/rvm/gems/ruby-2.0.0-p353#global/bin:/usr/local/rvm/rubies/ruby-2.0.0-p353/bin:/usr/local/rvm/bin:/usr/local/heroku/bin:/Users/anian/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/sm/bin:/opt/sm/pkg/active/bin:/opt/sm/pkg/active/sbin
My current bash profile:
~/.bash_profile
-bash: /Users/anian/.bash_profile: Permission denied
I did this: echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.bash_profile
But I got nothing but what you see below, Please help.
This is what I got:
anian$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
/opt/sm/pkg/active/bin/curl-config
/opt/sm/pkg/active/bin/ncurses5-config
/opt/sm/pkg/active/bin/ncursesw5-config
/opt/sm/pkg/active/bin/pkg-config
/opt/sm/pkg/active/bin/xml2-config
/opt/sm/pkg/active/bin/xslt-config
Warning: Homebrew's sbin was not found in your PATH but you have installed
formulae that put executables in /usr/local/sbin.
Consider setting the PATH for example like so
echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.bash_profile
I had to reset my machine altogether, it doesn't appear there is a way to reset the path and make sure everything is stable at the same time.

MongoDB installed via Homebrew not working

I installed MongoDB via Homebrew (following http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/) but it's not working.
Typing mongod at shell prompt gives me:
-bash: mongod: command not found
Not sure if I need to add something for Homebrew to my PATH env var?
I can see Mongo is installed under /usr/local/Cellar/mongodb – but am assuming I don't need to add everything I install via homebrew to the path? Also, assuming I can run mongod from any directory or am I actually meant to be in install directory?
When I run brew doctor I get:
Warning: You have unlinked kegs in your Cellar
Followed by a list of 3 items which includes MongoDB – but I'm not sure how I'm meant to link them?
Works perfectly
brew update
brew tap mongodb/brew
brew install mongodb-community#4.2
For latest version, check https://docs.mongodb.com/manual/release-notes/
You're getting this error because your 'brew' install failed to create the correct symlinks in /usr/local/bin. As a result, the shell can't find the mongo executables in your $PATH. You can fix this using the following steps:
Check the permissions on /usr/local/bin and make sure that you own that directory and have write permissions on it
$ ls -ld /usr/local/bin
Once you've fixed that, run 'brew link' to fix the symlinks
$ brew link mongodb
If you are on mongodb-community#4.0. You can try to reinstall with brew reinstall mongodb-community#4.0.
Then I get the following hint:
==> Caveats
mongodb-community#4.0 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have mongodb-community#4.0 first in your PATH run:
echo 'export PATH="/usr/local/opt/mongodb-community#4.0/bin:$PATH"' >> ~/.bash_profile
So you can just copy the echo command and restart your shell!
Copied from a different channel running these commands in the terminal updated the installation/configuration issues as described in OP
brew tap mongodb/brew
brew install mongodb-community
brew services start mongodb-community
I faced the same problem and this solution seemed to work for me. I had previously uninstalled mongodb and reinstalled it through homebrew which gave me a bunch of problems. This solution seemed to work just fine.
brew uninstall --force mongodb
brew cleanup -s mongodb
brew cleanup --prune-prefix
brew install mongodb
It works from the directory since the sh searches the ENV path and then the cwd for a program named mongod. I have been looking around a little and it seems that the default install of MongoDB (I am not a Mac user) does not install a rc or init script for which sh to understand it's running behaviour as stated here:
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/#using-mongodb-from-homebrew-and-macports
The packages installed with Homebrew and MacPorts contain no control
scripts or interaction with the system’s process manager.
If you have configured Homebrew and MacPorts correctly, including
setting your PATH, the MongoDB applications and utilities will be
accessible from the system shell. Start the mongod process in a
terminal (for testing or development) or using a process management
tool.
So you must actually define (as you said) MongoDBs path, here is an example: https://snipt.net/sido/installing-mongodb-on-os-x/
Edit: the example is not mine. I just stole it from it's user: https://snipt.net/sido/

Resources