Ruby not acting the same on Netlify as it does locally

I have had a website that uses Netlify to build from a github repo for over a year now. It uses vuepress and before the build is initiated a ruby script is ran to move around certain files as well as pull in other repos that contain documentation and such. Once the script is done then the site builds and everything is good.

I have gone through major updates to the site & other repos. I have added a lot of code to the ruby script due to that but everything works the way it is intended locally. The issue is when Netlify tries to build the site it errors out while running the ruby script.

The ruby script clones a list of repos to a temp directory and adjusts various files to their proper place for the website. Locally everything works correctly, but on Netlify once it completes the cloning of the repos and starts the adjustment process it errors out with no such file or directory even though it just cloned it.

What the log should look like (local)...
ruby prepare-docs.rb && vuepress build
>>> Reading docs repo
 -> Deleting docs if existing...
 -> Cloning naomi-docs
>>> Reading dev docs repo
 -> Deleting dev if existing...
 -> Cloning naomi-docs_dev
>>> Reading plugins repo
 -> Deleting docs if existing...
 -> Cloning naomi-plugins
>>> Reading plugins.csv
 -> Deleting temp if existing...
 -> Cloning https://github.com/NaomiProject/controlLED-plugin.git
 -> Cloning https://github.com/aaronchantrill/NaomiFrotz.git
 -> Cloning https://github.com/aaronchantrill/Naomi_Google_AIY_Voice_v1_Button.git
 -> Cloning https://github.com/aaronchantrill/Naomi-Google-Calendar.git
 -> Cloning https://github.com/aaronchantrill/respeaker_4mic_volume.git
 -> Cloning https://github.com/aaronchantrill/YoureWelcome.git
 --> controlLED-plugin
 ---> speechhandlers
 ---> led.png
 --> Naomi-Google-Calendar
 ---> speechhandlers
 ---> gcal.png
 --> NaomiFrotz
 ---> speechhandlers
 ---> frotz.png
 --> Naomi_Google_AIY_Voice_v1_Button
 ---> visualizations
 ---> GAIYVv1.png
 --> respeaker_4mic_volume
 ---> visualizations
 ---> seeed.png
 --> YoureWelcome
 ---> speechhandlers
>>> Migrating the introduction article
>>> Migrating logos
>>> Migrating plugins: Audioengines
 -> naomiaudio
>>> Migrating plugins: Speechhandlers
 -> Birthday
 -> Check-Email
 -> Clock
 -> controlLED-plugin
 -> HackerNews
 -> Life
 -> Mdpcontrol
 -> Naomi-Google-Calendar
 -> NaomiFrotz
 -> News
 -> Notification
 -> WWIS-Weather
 -> YoureWelcome
>>> Migrating plugins: Text to Intents
 -> Adapt
 -> Naomi
 -> Padatious
>>> Migrating plugins: Text to Speechs
 -> Cereproc
 -> Espeak
 -> Festival
 -> Flite
 -> GoogleTTS
 -> MaryTTS
 -> MicrosoftTTS
 -> SayOSX
 -> SvoxPico
>>> Migrating plugins: Speech to Texts
 -> ATTSpeech
 -> DeepSpeech
 -> GoogleCloud
 -> Julius
 -> Kaldi
 -> Pocketsphinx
 -> Witai
>>> Migrating plugins: Voice Activation Detections
 -> SNR_Vad
 -> WebRTCVAD
>>> Migrating plugins: Visualizations
 -> Naomi_Google_AIY_Voice_v1_Button
 -> respeaker_4mic_volume
>>> Writing plugin arrays to files for sidebar navigation
What the log looks like on Netlify...
ruby prepare-docs.rb && vuepress build
>>> Reading docs repo
 -> Deleting docs if existing...
 -> Cloning naomi-docs
 >>> Reading dev docs repo
 -> Deleting dev if existing...
 -> Cloning naomi-docs_dev
 >>> Reading plugins repo
 -> Deleting docs if existing...
 -> Cloning naomi-plugins
 >>> Reading plugins.csv
 -> Deleting temp if existing...
 -> Cloning https://github.com/NaomiProject/controlLED-plugin.git
 -> Cloning https://github.com/aaronchantrill/NaomiFrotz.git
 -> Cloning https://github.com/aaronchantrill/Naomi_Google_AIY_Voice_v1_Button.git
 -> Cloning https://github.com/aaronchantrill/Naomi-Google-Calendar.git
 -> Cloning https://github.com/aaronchantrill/respeaker_4mic_volume.git
 -> Cloning https://github.com/aaronchantrill/YoureWelcome.git
prepare-docs.rb:52:in `initialize': No such file or directory @ rb_sysopen - temp/controlLED-plugin/readme.md (Errno::ENOENT)
from prepare-docs.rb:52:in `open'
from prepare-docs.rb:52:in `block in <main>'
from prepare-docs.rb:49:in `glob'
from prepare-docs.rb:49:in `<main>'

I am at a lose on what is causing this issue and any help would be greatly appreciated. Here is a link to the ruby file if anyone wants to review it directly.

Hey @Longshotpro2,

If a build works locally and not on Netlify, the first thing to check would be dependency versions. By default, we run Ruby 2.6.2 on our Xenial build image (see https://github.com/netlify/build-image/blob/xenial/included_software.md).

You may want to check what you run locally. If you’re using a different version locally, you will need to specify this in your build settings. Let me know how this goes!

Hey @Pieparker,

I have not tested the script on new versions of ruby however I have had a .ruby-version file in the repo since the beginning setting the version to 2.4.3 and Netlify recognizes that and switches versions. Along with that since I have had this project on netlify since 2018 the site is built on Ubuntu Trusty 14.04 as well. Here is a build log for reference.

https://app.netlify.com/sites/projectnaomi/deploys/5eb89d5bbb916f00064a6043

Hey @Longshotpro2,

Understood. Taking a look at the error – No such file or directory @ rb_sysopen – I’m no Ruby expert but there’s a fair few similar issues out there!

@Pieparker,

This script is the extent of my ruby knowledge & experience so I am learning along the way. That being said, the linked stackoverflow talks about how to create a directory or directory tree if one does not already exist which I might have to consider further on in the script. However the current issue pulls directories I know exist because they are the cloned repo directories. Now if for some reason they do not exist that means that git is not cloning the repos correctly.

To eliminate all possibilities, I have submitted pull requests for the various repos that are cloned to change the file name from README.md to readme.md to make sure they all match as well as see if file name capitalization matters on Netlify vs locally.

I will update once all of the PR have been merged and I can test it.

Hey @Pieparker,

So that ended up being the issue… The various readme files in the repos that are cloned were mixed from all caps to lowercase. So when the ruby file on Netlify runs it was looking for the exact same capitalization that is in the script where as locally it recognized both naming schemes as being the same. Not sure what causes that to be different but nevertheless that was it.

Thank you for the help!

1 Like

Hiya,

Case sensitivity… who’d have thought? Good spot! Glad you resolved it and thanks for feeding back to us – it’s invaluable!