dyld: Library not loaded, Referenced from: Reason: image not found

We got into this issue when we were trying to install rails on the server. On the server, the ruby, and rails version we had were a bit upgraded. We wanted to downgrade both the ruby and rails version for an old project to run.

In the process of downgrading both the ruby and rails version, we had to do quite a lot of installation of different gems. Our ruby installation of 2.3.1 version was good but when we tried to install rails 4.2.6 then we got in the following error:

$ gem install rails -v 4.2.6
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.60.dylib
  Referenced from: /usr/local/bin/node
  Reason: image not found
Abort trap: 6

Reason of the issue

Actually, when we tried a lot of installation of gems and packages by mistake we broke the node path and that caused the above issue. After breaking the node path, we found that many services were not working. For example, we tried yarn start and that failed with the same error.

Solution of the issue

We had to upgrade the node to fix the node path using the following command.

$ brew upgrade node

In our case, the node update was needed but if it is not needed we simply fixing the node path will fix the issue.

Source:
dyld library was not loaded