Troubles upgrading from ruby 2.7 to 3.0 - error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING'

5.5k views Asked by At

I've been struggling with trying to upgrade rails 3.0 for about a week now.

I'm not entirely sure what the issue is but I was thinking it could be due to the fact that I have both rvm and rbenv.

I've followed the upgrade tutorial from gorails here: https://gorails.com/setup/osx/12-monterey

But whenever I run:

$ rbenv install 3.0.3

I get the following error:

In file included from compile.c:40:
./vm_callinfo.h:217:16: error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING'
    if (debug) rp(ci);
               ^
./internal.h:95:72: note: expanded from macro 'rp'
#define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING)

Here is also a look at my error logs:

In file included from compile.c:40:
./vm_callinfo.h:217:16: error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING'
    if (debug) rp(ci);
               ^
./internal.h:95:72: note: expanded from macro 'rp'
#define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING)
                                                                       ^
2 errors generated.
make: *** [compile.o] Error 1

I'm a junior dev who coded a majority of the time RoR but I truly do not understand this environment stuff, so if anyone has any resources that I could read up on that would help, it would be much appreciated. If I left out any crucial information, my apologies. Just let me know and I'll try to respond as quickly as possible

4

There are 4 answers

1
Travis Courtney On

Finally found a solution. Essentially there was an OS update and with that some command tool updates that weren't showing up. After forcing the update for the command tools it updated to rub 3.0.3 without any issues.

2
Piyush Awasthi On

Try this I hope that work for you

brew update
brew upgrade
brew install llvm
export PATH="/usr/local/opt/llvm/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/llvm/lib"
export CPPFLAGS="-I/usr/local/opt/llvm/include"
rbenv install 3.0.3
rbenv rehash
1
user2721861 On

I tried

sudo xcode-select -s /Library/Developer/CommandLineTools

then install ruby again. Hope that work for you

8
Wilbert Harriman On

The problem is caused by Xcode command line tools being outdated. Use the following script to force update Xcode command line tools.

sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install