Unable to upgrade v4.5.42 from, PHP 7.3 to PHP 7.4 and Migrate to v5

The error mentions PHANTOMJS_BIN_PATH which I don’t see in the screenshots?

Yes exactly. Neither do I. // PHANTOMJS_BIN_PATH isn’t even in the env file.

I need help on this please.

Not sure, is it possible you’re editing the wrong file?

Editing the wrong file. No.

Did you develop the v5 or was it outsourced?

We developed v5 in-house

That’s good to know.

So you can help with this error I assume?

Sorry, not sure what else to suggest

Ok Hillel

I have to say it’s not exactly confidence inspiring. Sure you’d agree.

You’ve been very patient and helpful and I know it’s frustrating as I have a client site that migrated without any issues.

Is there any other way of performing the migration other than using the UI or dumping the data?

Could the bad gateway request be due to a server timeout even though both sites are on the same server and same IP?

I suggest figuring out why the error points to PHANTOMJS_BIN_PATH

You can export/import data as CSV but the results won’t be as good as using the migration tool

Do you have an empty .env file I can use for v5?

v4: invoiceninja/.env.example at master · invoiceninja/invoiceninja · GitHub

v5: invoiceninja/.env.example at v5-stable · invoiceninja/invoiceninja · GitHub

Thanks

I did the migration again just to test and on the v4.5.42 site I got this error:

504 Gateway Time-out

But on the v5 website in the log the last line is this:

[2024-09-04 20:26:06] production.INFO: Completed🚀🚀🚀🚀🚀 at 2024-09-04 20:26:06  

Interesting. Seems the migration worked despite the error on the v4.5.42 site.

I still get the same error as above:

php artisan ninja:check-data
The environment file is invalid!
Failed to parse dotenv file due to an invalid name. Failed at [// PHANTOMJS_BIN_PATH].

Just seems odd to get an OK message in the log but an error from the CLI.

Maybe this can help?

It appears to be a common issue with Invoice Ninja going back a few years so I was hoping as it’s your software you might have found a solution:

And despite removing EVERY SINGLE space from the -env file I still get the following error:

php artisan ninja:check-data
The environment file is invalid!
Failed to parse dotenv file due to an invalid name. Failed at [// PHANTOMJS_BIN_PATH]

I have removed all spaces
I even wrote a new .env file from scratch
In addition to that I also checked every single line of code for a space that may have been at the end of a line.

NOTHING.

Really need your input here. It’s your software, you developed it in house, you’ve come across this issue before so must have found a solution in the last 4 years surely?

If you clear the file do you see the same error?

My guess is you’re editing the wrong file.

Here’s what I have found, this may be the cause of the issue…

https://stackoverflow.com/questions/55148397/laravel-5-8-artisan-commands-error-failed-to-parse-dotenv-file-due-to-an-inv

I found the cause of this problem.
It was because of line separator in .env file !
It must be CRLF not LF
My .env file was LF

So I ran the following command on the .env file:

cat -e .env

And got the following response:

APP_ENV=production$

That “$” symbol is at the end of every single line in the .env file so I suspect that would indicate that the file is using “LF” and should be using “CRLF”

I have tried using nano -env and also vi .env but neither of these options allows me to see and change the line seperator.

Can you help?

I copy/pasted your question to ChatGPT (something I assume you can do yourself)

To resolve the issue with line separators in your .env file, you’ll need to convert the line endings from LF (used in Unix-based systems) to CRLF (used in Windows systems). Here are a few ways you can do this, depending on the environment you’re working in:

Solution 1: Use dos2unix/unix2dos Command

If you are in a Unix-like environment, you can use the unix2dos command to convert LF to CRLF.

  1. Install the unix2dos package if it is not already installed:

bash

Copy code

sudo apt-get install dos2unix
  1. Convert the .env file to CRLF:

bash

Copy code

unix2dos .env

This will convert all the line endings in your .env file to CRLF.

Solution 2: Use a Text Editor (e.g., VS Code or Sublime Text)

If you have access to a GUI-based text editor like VS Code or Sublime Text, you can do the following:

  1. Open the .env file in VS Code or Sublime Text.
  2. In VS Code, you’ll see the current line ending (LF or CRLF) displayed at the bottom right of the screen.
  3. Click on “LF” (if that’s the current line ending) and select “CRLF” from the list to convert it.
  4. Save the file.

Solution 3: Using sed Command (For Unix-based Systems)

You can also use the sed command to replace the LF line endings with CRLF:

  1. Run the following command to replace LF with CRLF:

bash

Copy code

sed -i 's/$/\r/' .env

This command adds a \r (Carriage Return) at the end of each line, which will make it use CRLF.

Solution 4: Using Notepad++ (Windows)

If you are on a Windows machine, you can open the .env file in Notepad++:

  1. Open the .env file in Notepad++.
  2. Go to the Edit menu, then select EOL Conversion, and choose Windows (CR LF).
  3. Save the file.

This should resolve the issue with the line endings. After this, run your Laravel application again to see if the issue is resolved.

Let me know if you need further assistance!

Thanks.

I have tried a few editors and they all open the file as plain text so I cannot edit the line separators.

I managed to do it and the following command shows the correct file line endings:

file -k .env
.env: ASCII text, with CRLF line terminators

But the following command still throws up an error:

php artisan ninja:check-data
The environment file is invalid!
Failed to parse dotenv file due to an invalid name. Failed at [// PHANTOMJS_BIN_PATH].