Goal: You need to compile Ruby for whatever reasons.
Background: You've read Oliver's guide. However, your goal does not match with those in Oliver's guide. Therefore, you don't need to do all the things in the guide and start to skim through the text and to scan for commands useful to you. (This is an essential skill to survive in *nix. [1])
Problem: You've found someuseful commands, and tried working out their dependencies. Nonetheless, you missed out some important commands and thus the dependencies were wrong. Unfortunately, you're unaware of such careless mistake and continued the process, before being stopped by the compiler's error message.
In this case, you found the following commands useful.
$ curl # Substitute [version-number] with that of your downloaded archive. # If you're NOT sure, use `ls' to list the files inside your folder. $ tar -xvzf ruby-[version-number].tar.gz $ cd ruby-[version-number] $ makeTherefore, you ran all of these commands. Expecting to get things done and to proceed to the next step, you got an error message from the compiler.
Trial: Using a part of the compiler's error message as the query string a search engine, you get some other web pages on the same or similar topics. If you could find blog entries like this some, they might have links to other similar web pages, so you've got even more to read.
I've found DiStasio's article, which contains a hyperlink to Ladd's essay. I tried issuing the following commands accroding to the instructions there.
# Suppose that the current working directory is the same as the one in the above command list.
# If you're NOT sure, use `pwd' to check it.
$ cd ext/openssl
$ make
$ sudo make reinstall # I'd installed the wrong version of Ruby.
Lacking patience to read the blogs, knowledge of using makefiles and experience of compiling softwares from their source code, I don't know how to uninstall the wrong version of Ruby. Are there any make uninstall
command?I tried searching for
reinstall
and uninstall
in the makefile
, and failed to find any. Then, I realised that using search engines to answer my questions was inefficient. Reading the official manual of Make wouldn't be effective. Thus, without knowing the truth, I just try the last line of the above list of commands.The
make reinstall
command successfully triggered a reinstallation of Ruby, but after running the command, I still received complaints form the compiler. Having no idea on the process, I did the same thing again: copied a part of the message and googled it, and ended up with further more pages to read. The amount of tab pages in my current browser window is too high and this stopped me from opening more web pages on Ruby compilation errors on Google's search result in a new tab.It took me some time to find out that I overlooked the command below
$ sudo apt-get install build-essential zlib1g-dev libssl-dev libreadline-dev libyaml-dev libcurl4-openssl-dev curl git-core python-software-propertiesIn Oliver's guide, the above command is right aobve those commands for compiling and installing Ruby. Therefore, I installed them, and tried rebuilding Ruby by running
make
and sudo make reinstall
in my ruby-[version-number]
. (i.e. my Ruby source folder) It failed again. Without changing the current working directory directory in the above command list, I did the following because of Ladd's web page.$ make $ sudo make reinstallBut it failed again. Maybe I need to go back to
ruby-[version-number]
, recompile the source code and reinstall Ruby again. So using the same current working directory as the one in the above command list, I did the following thing.$ cd ../.. # For changing the current working directory to `ruby-[version-number]'.
$ make
$ sudo make reinstall
Things still went wrong! I remembered the make clean
command, so without changing the current working directory, I ran the following commands.
$ make clean $ make $ sudo make reinstallRemark: With the command
dkpg -l | grep ruby
, I realised that make clean
doesn't uninstall Ruby. It just deletes all compiled files in ruby-[version-number]
.It still wouldn't compile with the OpenSSL feature. However, some features that had failed to compile before I had run the command
make clean
could be compiled.This inspired me to run the following commands.
$ cd ext/openssl $ make clean $ make $ sudo make reinstallHowever, I still got errors. There was a problem in getting the file
ossl.o
work. (I've forgotten the exact name of that file, and I couldn't find web pages about the same error.) I ignored the message and ran the following commands.$ cd ../.. $ make clean $ make $ sudo make reinstallBut it still didn't go right. After running the commands
make
and make clean
for a number of times, I eventually worked out a solution for my problem.
Solution:
- Run the command
make clean
in both theruby-[version-number]
andruby-[version-number]/ext/openssl
directories. -
Run
make
inruby-[version-number]
to compile the source code.
Some errors like "Failed to compile gdbm" will come out.
It depends on your needs. Having no clue on whatgdbm
is, I just proceed to the reinstallation of Ruby. -
Run the command
sudo make reinstall
inruby-[version-number]
.
Then the commandgem install bundle
in Oliver's guide should work.
- Always figure out the dependencies of a package.
- Be careful and patient while reading instructions on commands.
- Always clear all compiled files before any recompilation.
Reference:
[1]: http://user.frdm.info/ckhung/a/c013.php
No comments:
Post a Comment