All original content is created in Ukrainian. Not all content has been translated yet. Some posts may only be available in Ukrainian.Learn more

[Fix] No such file or directory @ rb_sysopen - tmp/pids/server.pid

Table of contentsClick link to navigate to the desired location
This content has been automatically translated from Ukrainian.
Sometimes it happens that the tmp/pids folder gets lost on the local machine. It is in gitignore for obvious reasons. As a result, the server cannot start and shows the error:
* Listening on http://0.0.0.0:3000bundler: failed to load command: puma (/Users/memecode/.rbenv/versions/3.3.5/bin/puma)/Users/memecode/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/puma-6.5.0/lib/puma/launcher.rb:316:in `write': No such file or directory @ rb_sysopen - tmp/pids/server.pid (Errno::ENOENT)
The error message is quite literal:
No such file or directory @ rb_sysopen - tmp/pids/server.pid

Let's fix the error

We need to create the tmp/pids folder manually. To do this, you can run the following command in the terminal:
mkdir -p tmp/pids
We restart the server, and it should successfully start by creating the server.pid file.
Out of curiosity, you can check:
ls tmp/pids 
It should show the file:
server.pid

What is server.pid for?

The server.pid file is used by the Rails server to store the process identifier (PID) of the active server process. This PID helps the system track which process is responsible for the server. Before starting a new server, Rails checks for the existence of this file. If the file exists and the process it points to is still active, Rails does not allow starting a new server to avoid conflicts.
In other words, this is what prevents you from accidentally starting a second server using rails s in a neighboring terminal tab.
Additionally, the file helps properly shut down the server. When the server stops, the server.pid file is automatically deleted, signaling that the server is no longer running and can be restarted without issues. If the file is missing, Rails creates it upon startup. In the case where the file exists but the process it refers to is no longer active, this may cause an error, and then the file needs to be deleted manually before restarting the server.

This post doesn't have any additions from the author yet.

What does the ACID principle mean in programming?
24 Sep 20:31

What does the ACID principle mean in programming?

meme code
meme code@memecode
What is Convention over Configuration (in the context of RoR and beyond)?
26 Sep 07:47

What is Convention over Configuration (in the context of RoR and beyond)?

meme code
meme code@memecode
Rounding Decimal Numbers: Mathematical Rules, JavaScript, and Ruby
18 Oct 12:59

Rounding Decimal Numbers: Mathematical Rules, JavaScript, and Ruby

meme code
meme code@memecode
[Fix] Factory not registered: "user" (KeyError) (FactoryBot / Rails 7)
07 Dec 10:46

[Fix] Factory not registered: "user" (KeyError) (FactoryBot / Rails 7)

meme code
meme code@memecode
What is PORO in Ruby?
08 Dec 12:46

What is PORO in Ruby?

meme code
meme code@memecode
What is the difference between spec_helper.rb and rails_helper.rb in RSpec?
08 Dec 13:53

What is the difference between spec_helper.rb and rails_helper.rb in RSpec?

meme code
meme code@memecode
What you need to know to build a successful freelance career in IT
23 Dec 16:03

What you need to know to build a successful freelance career in IT

meme code
meme code@memecode
Virtual cloud server: what it is and what makes it special
03 Jan 10:58

Virtual cloud server: what it is and what makes it special

meme code
meme code@memecode
[Fix] Heroku / SearchBox addon - indexing error "The client is unable to verify that the server is Elasticsearch"
31 Jan 13:09

[Fix] Heroku / SearchBox addon - indexing error "The client is unable to verify that the server is Elasticsearch"

meme code
meme code@memecode
06 Feb 15:31

Fix error [DEPRECATION] #adapters is deprecated. Use #profiles instead. (Codecov / docile)

meme code
meme code@memecode
What is a Promise in JavaScript and how to quickly understand its essence?
18 Feb 11:01

What is a Promise in JavaScript and how to quickly understand its essence?

meme code
meme code@memecode
The structure of Promise (JavaScript) and how to work with it
18 Feb 14:33

The structure of Promise (JavaScript) and how to work with it

meme code
meme code@memecode