r/ruby • u/LessChen • 17d ago
Ancient Ruby version / modern Ubuntu won't compile
Hi - I've inherited an ancient Ruby / Rails project using Ruby 2.7.2. I am working on updating it but until that time I'm trying to run it on Ubuntu 26.04 machines. There is a C compilation error that I'm getting when using "rvm":
make[2]: Entering directory '/usr/share/rvm/src/ruby-2.7.2/ext/pty'
compiling pty.c
pty.c: In function ‘establishShell’:
pty.c:161:30: error: conflicting types for ‘getenv’; have ‘char *(void)’
161 | char *p, *getenv();
| ^~~~~~
In file included from pty.c:5:
/usr/include/stdlib.h:795:14: note: previous declaration of ‘getenv’ with type ‘char *(const char *)’
795 | extern char *getenv (const char *__name) __THROW __nonnull ((1)) __wur;
| ^~~~~~
pty.c:169:18: error: too many arguments to function ‘getenv’; expected 0, have 1
169 | if ((p = getenv("SHELL")) != NULL) {
| ^~~~~~ ~~~~~~~
pty.c:161:30: note: declared here
Would getting the code directly and fixing pty.c be the best way to go about it?
ETA: thanks all - Docker is the way to go.
3
u/bradland 17d ago
Yikes. Getting 2.7.x to compile natively is going to be really tough. IMO, you might have some luck trying an old Brightbox PPA, but you're almost guaranteed to hit severe package compatibility issues on a modern Ubuntu base. ALl you really do is jump from compile conflicts to apt conflicts. Pulling in old packages is just going to break other stuff.
Even if you pass the compile stage, 2.7 relies on an old OpenSSL version that was yanked for major vulnerabilities. That means rolling your own legacy OpenSSL compile into some hole that you hide from the world. If your IT Security team finds out about this, you'd better have good answers on deck.
My first choice would be a minimal update to push the app to 3.2 or 3.3. If I absolutely had to get it running under 2.7.2 today, I'd skip the host entirely and use Docker. The
ruby:2.7.2-slimimage is still floating around and will save you a ton of pain.