Issue #15862 has been updated by mame (Yusuke Endoh).

Status changed from Open to Third Party's Issue

I think this issue is a bug or spec of rb-inotify.  If it is a bug, it shou=
ld be fixed.  If it is a spec, rails should not use rb-inotify in such an e=
nvironment.  Anyway, you have already filed a ticket in that bug tracker: h=
ttps://github.com/guard/rb-inotify/issues/94.  Please want for the answer.

This tracker is for discussing a bug and feature of ruby itself.  I'm unsur=
e what you want to discuss in this ticket.  I'm closing this as Third Party=
's Issue.  Let me know if you have any specific topic about ruby itself.

----------------------------------------
Bug #15862: Segmentation fault when running Rails commands
https://bugs.ruby-lang.org/issues/15862#change-78076

* Author: destrozates (Socrates Medina)
* Status: Third Party's Issue
* Priority: Normal
* Assignee: =

* Target version: =

* ruby -v: ruby 2.6.3p62 (2019-04-16 revision 67580) [armv7l-linux-eabihf] =
and ruby 2.5.5p157 (2019-03-15 revision 67260) [armv7l-linux-eabihf]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
I=B4ve been trying to install rbenv, ruby and rails in my Raspberry Pi 3 B+=
 in the past couple of days and after some issues here and there, I've mana=
ged to get everything installed with no errors

With rbenv I installed both Ruby 2.6.3 and Ruby 2.5.5
Using Rails 5.2.3

and with both ruby versions I am getting the same problem when I execute th=
e command:
```
rails server
```

### Steps to reproduce

1) On a Raspberry Pi install rbenv using brew
```
brew install rbenv
```

2) Then use the following command to install ruby
```
rbenv install 2.6.3
``` =


3) Then install rails:
```
gem install rails -v 5.2.3
```

4) Create a new folder to hold your application and go to that folder:
```
$ cd                  # Change to the home directory.
$ mkdir environment     # Make a environment directory.
$ cd environment/       # Change into the environment directory.
```

5) Use rails to create the application inside the previous folder:
```
rails _5.2.3_ new hello_app
```

6) Go to the recently created 'hello_app' folder
```
cd hello_app
```
7) Start the rails server
```
rails server
```
### Expected behavior

```
pi@raspberrypi:~/environment/hello_app $ rails server
=3D> Booting Puma
=3D> Rails application starting on http://localhost:3000
=3D> Run `rails server -h` for more startup options
=3D> Ctrl-C to shutdown server
```
And then it should just stay there to be able to access the web app on the =
address indicated

### Actual behavior

First, the output shows this:
```
pi@raspberrypi:~/environment/hello_app $ rails server
=3D> Booting Puma
=3D> Rails 5.2.3 application starting in development =

=3D> Run `rails server -h` for more startup options
```
And then the contents of the text file in the next link are shown.

Here is a link with the whole output:

https://www.dropbox.com/s/gjgo81zqeekfnvt/railsservererror.txt?dl=3D0
### System configuration

**Ruby version**: I=B4ve tried with both 2.6.3 and Ruby 2.5.5
**Rails version**: I've tried with 6.0.0.rc1 and with 5.2.3
**Puma version**: I've tried with 3.12.1 and a previous one too

### Workaround

User @dannyfallon  helped me with a workaround and explanation as follows f=
rom the Puma github site because I thought this was an issue with the Puma =
web server, but I was wrong:

> According to your segfault's `Control frame information` you never even r=
eached Puma. I would think that since Puma was never reached if you swapped=
 `puma` in your gemfile for `thin` or `webrick` you still wouldn't be able =
to run `rails server`. =

> =

> When you run `rails server` the application does a bunch of stuff before =
actually passing off the `Rails::Application` to a Rack server to run. In d=
evelopment Rails creates an `EventedFileWatcher` to watch for file changes =
so it can reload your app without you having to stop/start your server all =
the time. This uses the `listen` gem, which under the hood uses some OS-spe=
cific file events so it doesn't have to keep polling. In trying to create a=
 watch (which `listen` does through `rb-inotify` for Linux), Ruby encounter=
ed a segmentation fault:
> =

> ```
> /home/pi/.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/rb-inotify-0.10.0=
/lib/rb-inotify/notifier.rb:57: [BUG] Segmentation fault at 0xe92d000e
> ruby 2.5.5p157 (2019-03-15 revision 67260) [armv7l-linux-eabihf]
> =

> -- Control frame information --------------------------------------------=
---
> c:0095 p:---- s:0527 e:000526 CFUNC  :inotify_init
> c:0094 p:0041 s:0523 e:000522 METHOD /home/pi/.rbenv/versions/2.5.5/lib/r=
uby/gems/2.5.0/gems/rb-inotify-0.10.0/lib/rb-inotify/notifier.rb:57 [FINISH]
> ```
> =

> Because `rb-inotify` is using FFI and some C functions, when things go wr=
ong it does tend to blow up badly with segmentation faults.
> =

> There's lots of stuff you can do if you want to go deeper like report a b=
ug over at FFI, attempt to recompile Ruby from source, test `inotify` on yo=
ur distro outside of Ruby but you probably just want to get on with some de=
velopment given you've been at it a few days.
> =

> I believe to fix this you can open `config/development.rb` and replace th=
is:
> =

> ```ruby
>   # Use an evented file watcher to asynchronously detect changes in sourc=
e code,
>   # routes, locales, etc. This feature depends on the listen gem.
>   config.file_watcher =3D ActiveSupport::EventedFileUpdateChecker
> ```
> =

> with =

> =

> ```ruby
>   # Use a simple file watcher to detect changes in source code
>   config.file_watcher =3D ActiveSupport::FileUpdateChecker
> ```
> =

> Caveat: The `EventedFileWatcher` is supposed to use OS events to detect f=
ile changes. The =

> `FileWatcher` will poll for changes. This may slow down reloads or cause =
higher system load.

_Originally posted by @dannyfallon in https://github.com/puma/puma/issues/1=
797#issuecomment-493190148_

The solution proposed by @dannyfallon  actually allowed me to start the Web=
 Server, but I was wondering if the people here at rb-inotify could give me=
 a hand to try to figure out what went wrong and if there is anything I can=
 do to fix this problem and be able to use
```
config.file_watcher =3D ActiveSupport::EventedFileUpdateChecker
```

Sorry for the long post...

Awaiting your comments.

P.S.: by the way, I get the same segmentation fault when I try to create a =
new rails app with rails version 6.0.0.rc1:

```
rails _6.0.0.rc1_ new hello_app
```
but if I use version 5.2.3 I don=B4t get the error

```
rails _5.2.3_ new hello_app
```

I also get the segmentation fault when I try to execute the following rails=
 command:
```
rails generate scaffold User name:string email:string
```

Thanks,



-- =

https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=3Dunsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>