Ruby "Is a directory @ io_fread" error

Hey Middleman community,

I could need some help.

I have installed Middleman + Gulp from https://github.com/joshukraine/middleman-gulp which seemed to work fine, but I get an ERROR -- : exception while processing events: Is a directory @ io_fread error which I cannot interpretate. I guess it’s more Ruby or environment related than an Middleman issue, but Google shows only very few results for this error - one is a thread from this forum which never got an answer (External pipeline source subdirectories?).

A consequence of this error is that the asset files in the .tmp directory (stylesheet, javascript) and being build, but they are not included in the directory structure (I can see the files in e.g. ./.tmp/assets/stylesheets, but in the generated sites they are not availbale - 404).

Even more obscure, although the error was thrown from the first dynamic build on, the generated site seemed to work fine first and broke after re-starting the middleman server… when starting a completely new site from strach (from the above mentioned github repo), sometimes this first times the site is working fine, sometimes not. The error message is always thrown.

No difference when making a production build (same issue).

Does anyone have an idea what’s going wrong?

Thanks
Arne

arne@torndirrup:/mnt/c/Users/arneh/dev/test2$ bundle exec middleman server
warning: parser/current is loading parser/ruby23, which recognizes
warning: 2.3.7-compliant syntax, but you are running 2.3.1.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
== The Middleman is loading
== Executing: `npm run development`
== External: > middleman-gulp@2.3.5 development /mnt/c/Users/arneh/dev/test2
== External: > NODE_ENV=development gulp default
== External: [08:53:32] Using gulpfile /mnt/c/Users/arneh/dev/test2/gulpfile.js
== External: [08:53:32] Starting 'development'...
== External: [08:53:32] Starting 'clean'...
== External: [08:53:32] Finished 'clean' after 35 ms
== External: [08:53:32] Starting 'css'...
E, [2018-05-10T08:53:38.373860 #13760] ERROR -- : exception while processing events: Is a directory @ io_fread - /mnt/c/Users/arneh/dev/test2/.tmp/assets Backtrace:
 -- /var/lib/gems/2.3.0/gems/middleman-core-4.2.1/lib/middleman-core/util/binary.rb:70:in `read'
 -- /var/lib/gems/2.3.0/gems/middleman-core-4.2.1/lib/middleman-core/util/binary.rb:70:in `file_contents_include_binary_bytes?'
 -- /var/lib/gems/2.3.0/gems/middleman-core-4.2.1/lib/middleman-core/util/binary.rb:38:in `binary?'
 -- /var/lib/gems/2.3.0/gems/middleman-core-4.2.1/lib/middleman-core/sitemap/resource.rb:175:in `binary?'
 -- /var/lib/gems/2.3.0/gems/contracts-0.13.0/lib/contracts/method_reference.rb:43:in `send_to'
 -- ... ...

Some more information which might be useful:

Windows Subsystem Linux / Ubuntu

arne@torndirrup:/mnt/c/Users/arneh/dev/test2$ ruby -v
ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]

arne@torndirrup:/mnt/c/Users/arneh/dev/test2$ ls -la .tmp/
total 0
drwxrwxrwx 0 root root 512 May 10 08:53 .
drwxrwxrwx 0 root root 512 May 10 07:47 ..
drwxrwxrwx 0 root root 512 May 10 08:53 assets
arne@torndirrup:/mnt/c/Users/arneh/dev/test2$ ls -la .tmp/assets/
total 0
drwxrwxrwx 0 root root 512 May 10 08:53 .
drwxrwxrwx 0 root root 512 May 10 08:53 ..
drwxrwxrwx 0 root root 512 May 10 08:53 images
drwxrwxrwx 0 root root 512 May 10 08:53 stylesheets
arne@torndirrup:/mnt/c/Users/arneh/dev/test2$ ls -la .tmp/assets/stylesheets/
total 1892
drwxrwxrwx 0 root root    512 May 10 08:53 .
drwxrwxrwx 0 root root    512 May 10 08:53 ..
drwxrwxrwx 0 root root    512 May 10 08:53 bootstrap
-rwxrwxrwx 1 root root 963907 May 10 08:53 landio.css
-rwxrwxrwx 1 root root 969645 May 10 08:53 site.css

I don’t do gulp, but just out of curiosity:

Try finding where /mnt/c/Users/arneh/dev/test2/.tmp/assets comes from and add / at the end of (I assume) some config-string, where the assets is defined. Seems that some process (middleman-core-4.2.1/lib/middleman-core/util/binary.rb) is trying to read a directory as file and detect if it’s binary.

Thanks, that definitely pointed be in the right direction.

It’s some kind of timing / race condition issue. I played around with details in the gulpfile and even tried a different systen (OpenSuSe with Ruby 2.5.1 instead Ubuntu with Ruby 2.3.0) with the result that the error always occurs, but at different stages when performing the dev build (sometimes when processing the scss, then when processing the js etc.).

If I omit the clean part in Gulp and also set debug: false it works (for now). I was pretty sure the error is related to the clean task from Gulp as then directories and files are being deleted first… but when setting debug: true in the gulpfile, I still get the error.

I am a Gulp newbie actually. I guess I should deal a little more with Gulp. Or it’s more a timing issue of Middleman’s external asset pipeline. I will try to find out.

Thanks for far, komor72!

Ok, it’s this known issue:

I further investigated and also started a totally new site using Middleman + Yarn + Webpack and ran into a very similar issue again. I had a chance to run Middleman on a friend’s Mac - everythings works well then.

With my start-over using Middleman / Yarn / Webpack from strach I did not have the issue when making the build, so my workaround for now is:

bundler exec middleman build
cd build
python -m SimpleHTTPServer

Not perfect, but works.