snipe / snipe-it

A free open source IT asset/license management system
https://snipeitapp.com
GNU Affero General Public License v3.0
10.84k stars 3.14k forks source link

upgrade.php is missing #15200

Open iamjustingraves opened 1 month ago

iamjustingraves commented 1 month ago

Debug mode

Describe the bug

Upgraded from 7.0.6 to 7.0.7 a while back with Git. Looking to upgrade to the latest release of 7.0.10. upgrade.php is completely missing from my install directory. I grabbed upgrade.php from the backup folder and run php upgrade.php. When I do that, the version downgrades to 7.0.4. If I do a Git Pull, there are a ton of errors about untracked files and commits. This install is running on Windows.

Reproduction steps

  1. Open Git as admin
  2. Navigate to snipe install folder
  3. Run php upgrade.php ...

Expected behavior

To successfully update to the latest version.

Screenshots

No response

Snipe-IT Version

7.0.7

Operating System

Windows Server 2016

Web Server

IIS

PHP Version

8.1.24

Operating System

Windows 11

Browser

Edge

Version

127.0.2651.74

Device

No response

Operating System

No response

Browser

No response

Version

No response

Error messages

No response

Additional context

No response

TUmphress commented 1 month ago

I am having the same issue. No longer have upgrade.php. I am currently on Version v7.0.9 - build 14371 (master), which was upgraded to via php upgrade.php. I was looking to to to v7.0.10.

snipe commented 1 month ago

I'm not even sure how you'd end up in a situation like this though. The file is correctly in the repo: https://github.com/snipe/snipe-it/blob/master/upgrade.php

GitHub
snipe-it/upgrade.php at master · snipe/snipe-it
A free open source IT asset/license management system - snipe/snipe-it
brianhoganm commented 1 month ago

I've had this issue for awhile. So every time I go to upgrade, it says that it's missing. So I always have to make a copy of the upgrade.php file and paste it in the SNIPEIT directory in order to run it.

snipe commented 1 month ago

How is that even possible though? A git pull should be pulling down whatever is in the repo, and the file is clearly in the repo. I'm honestly baffled.

Callandt commented 1 month ago

Same problem here. Every time I want to upgrade "upgrade.php" is gone.

iamjustingraves commented 1 month ago

@snipe If I manually run a git pull, it aborts with 2 different errors. The first, "error: Your local changes to the following files would be overwritten by merge:". Then proceeds to reference a bunch of files that I'll happily share. The second "error: The following untracked working tree files would be overwritten by merge:". Then shares more files. The git pull aborts.

I've snapshotted my VM and then cleaned out all the referenced files, copied the upgrade.php from a backup and dropped it into my prod site, then do a git pull successfully. However, then when running php upgrade.php, the script terminates immediately.

brianhoganm commented 1 month ago

@snipe If I manually run a git pull, it aborts with 2 different errors. The first, "error: Your local changes to the following files would be overwritten by merge:". Then proceeds to reference a bunch of files that I'll happily share. The second "error: The following untracked working tree files would be overwritten by merge:". Then shares more files. The git pull aborts.

I've snapshotted my VM and then cleaned out all the referenced files, copied the upgrade.php from a backup and dropped it into my prod site, then do a git pull successfully. However, then when running php upgrade.php, the script terminates immediately.

Yup - I had that issue as well. Have you just copy the upgrade.php from the master and just copy and paste it in your directory and than do a pull? Usually this works for me. I just keep a copy of the upgrade.php on my desktop. This is so weird that the upgrade.php file gets deleted.

snipe commented 1 month ago

Yeah, I can't think of a reason why that would be true.

Does the upgrade.php file get deleted right after it's run somehow?

iamjustingraves commented 1 month ago

If I do the aforementioned above and then run a php upgrade.php, the upgrade.php file remains, the command just immediately ends without performing any action.

TUmphress commented 1 month ago

If it is helpful, this is the list of file related issues I get when I run a git pull before it aborts. I am running on a Windows server and my current Snipe-IT version is 7.0.9. We are not running in a container.

`C:\inetpub\assets>git pull remote: Enumerating objects: 38, done. remote: Counting objects: 100% (38/38), done. remote: Compressing objects: 100% (16/16), done. remote: Total 38 (delta 25), reused 29 (delta 22), pack-reused 0 Unpacking objects: 100% (38/38), 53.72 KiB | 50.00 KiB/s, done. From https://github.com/snipe/snipe-it 24d948a3f..b83d148b3 develop -> origin/develop

GitHub
GitHub - snipe/snipe-it: A free open source IT asset/license management system
A free open source IT asset/license management system - snipe/snipe-it
snipe commented 1 month ago

@TUmphress All of those are files we changed tho, so I'd expect them to light up during a git pull, but unless permissions or line endings changed, they shouldn't show as changed locally on your machine.

marcusmoore commented 1 month ago

Is it possible upgrade.php is included in a global gitignore? I don't think it would cause what is happening but something that came to mind...

TUmphress commented 1 month ago

@TUmphress All of those are files we changed tho, so I'd expect them to light up during a git pull, but unless permissions or line endings changed, they shouldn't show as changed locally on your machine.

That makes sense to me, but what I pasted is what I get when running git pull from an administrative command prompt. Should I be running differently? This just started for me after updating to 7.0.9, prior, updates worked great.

snipe commented 1 month ago

I honestly don’t know - we’re only hearing a few reports of this issue, so it’s hard to track down to be honest 😔 My best guess is that permissions might have changed - you shouldn’t generally have to run the upgrader as root/admin, but if that’s how you usually do it, it shouldn’t be triggering local changes. I’ve got my team looking this, but being unable to reproduce this makes it tough :(

uberbrady commented 1 month ago

One thing I'm seeing consistently here - these all seem like Windows machines? I'm wondering if some of the automatic git things that change 'newlines' to 'carriage-return/newlines' for Windows machines might be silently changing things? And then that's why git seems to think that files have been modified.

uberbrady commented 1 month ago

One thing you should be able to do is try git stash - which should 'hide' your local changes. Then you should be able to do git checkout upgrade.php and it should pull that back down onto your box.

I think there's a setting to disable the line-endings stuff but I'm going to have to play around with that for a little bit to see if I can figure out where that setting is, and what the implications of it might be.

TUmphress commented 1 month ago

The git stash does imply that it is something with the line endings. C:\inetpub\assets>git stash warning: in the working copy of 'composer.lock', LF will be replaced by CRLF the next time Git touches it

I was then able to do the git checkout upgrade.php and get just the upgrade.php file. and attempt to run php upgrade.php. I am still getting the normal _ERROR: Failed to retrieve remote requirements from https://raw.githubusercontent.com/snipe/snipe-it/master/.upgrade_requirements.json_ error. (this has been happening for awhile now) Run again with the skip checks and I am now getting this error after the Step 4: Backing up database header: In trustedproxy.php line 60:

Undefined constant Illuminate\Http\Request::HEADER_X_FORWARDED_ALL

Something went wrong with your backup. Aborting!

Callandt commented 1 month ago

Small update from my side: I had the same issue and when I did "git stash", "git checkout upgrade.php" and "php upgrade.php" I got downgraded from 7.0.9 to 7.0.4.

Then I downloaded the latest upgrade.php version from github but I couldn't upgrade because the script didn't continue in the beginning (see picture). IMG_6898

When I downloaded an older version from upgrade.php (version from 2 months ago) and replaced it with the current file it upgraded without troubles to 7.0.10

iamjustingraves commented 1 month ago

From which release did you grab upgrade.php to get this to work?

Callandt commented 1 month ago

From which release did you grab upgrade.php to get this to work?

https://github.com/snipe/snipe-it/blob/0a5e58201ac73e7ac53a5b7bcf46986abc48d8df/upgrade.php

iamjustingraves commented 1 month ago

Thanks @Callandt. I finally got my instance to 7.0.10. Here's what worked for me.

git reset --hard git add * git stash git pull

Replace the upgrade.php script with the version here: https://github.com/snipe/snipe-it/blob/0a5e58201ac73e7ac53a5b7bcf46986abc48d8df/upgrade.php

Successfully completed but I still had to apply --skip-compatibility-php-checks

GitHub
snipe-it/upgrade.php at 0a5e58201ac73e7ac53a5b7bcf46986abc48d8df · snipe/snipe-it
A free open source IT asset/license management system - snipe/snipe-it
TUmphress commented 1 month ago

Thanks @iamjustingraves, your steps above also worked for me.

NOTE: My upgrade.php file has disappeared from my install directory again. I did notice this message show up while the upgrade.php was running (copied from the link above).


STEP 6: Pulling latest from Git (master branch):

Git is installed. Already on 'master' warning: in the working copy of 'upgrade.php', LF will be replaced by CRLF the next time Git touches it error: unable to create file upgrade.php: Permission denied fatal: Could not reset index file to revision 'HEAD'. -- Saved working directory and index state WIP on master: 9350a2018 Include accessories count -- M upgrade.php Your branch is up to date with 'origin/master'. -- Already up to date.

So, I will have to do some hoop jumping to run the next upgrade. Not sure why there would be a permissions error. I had copied the downloaded upgrade.php file into the folder so that it would inherit the same permissions as the rest of the files in the directory. The rest of the files upgraded just fine.

snipe commented 1 month ago

This is honestly so bizarre. I'm sure we'll find a smoking gun somewhere, but this is just so strange.

jsdoptel commented 1 month ago

Thanks @Callandt. I finally got my instance to 7.0.10. Here's what worked for me.

git reset --hard git add * git stash git pull

Replace the upgrade.php script with the version here: https://github.com/snipe/snipe-it/blob/0a5e58201ac73e7ac53a5b7bcf46986abc48d8df/upgrade.php

Successfully completed but I still had to apply --skip-compatibility-php-checks

GitHubsnipe-it/upgrade.php at 0a5e58201ac73e7ac53a5b7bcf46986abc48d8df · snipe/snipe-itA free open source IT asset/license management system - snipe/snipe-it

I have the same issue as @iamjustingraves .

I did all the same commands like you and just before to do php upgrade.php --skip-php-compatibility-checks, I needed to do composer update because some laravel packages was missing and got error 500 on the SnipeIT website.

After this, the update goes well and I'm now on 7.0.10 version. But immediately after the update, the upgrade.php file have been deleted again.

So weird

GitHub
snipe-it/upgrade.php at 0a5e58201ac73e7ac53a5b7bcf46986abc48d8df · snipe/snipe-it
A free open source IT asset/license management system - snipe/snipe-it
snipe commented 1 month ago

Long shot here, but can all of you let me know what anti-virus you're running? We do use php_exec() in that file, which some anti-virus programs will automatically sandbox.

jsdoptel commented 1 month ago

Long shot here, but can all of you let me know what anti-virus you're running? We do use php_exec() in that file, which some anti-virus programs will automatically sandbox.

On my hand, I use Cortex XDR

snipe commented 1 month ago

I mean specifically on the server (wherever your snipe-it install is located), not your local hard drive, if that wasn't clear.

@jsdoptel - do you have access to the sandbox to see what it might have thought was harmful and moved?

jsdoptel commented 1 month ago

I mean specifically on the server (wherever your snipe-it install is located), not your local hard drive, if that wasn't clear.

@jsdoptel - do you have access to the sandbox to see what it might have thought was harmful and moved?

Yes exactly, that's the server's antivirus when I'm talking about Cortex XDR.

I took a look into Cortex Antivirus dashboard to see any incident/quarantine file about this server but I don't see anything related to this.

If you're talking about another thing when you're saying to have access to the sandbox, let me know!

Thanks for your help.

TUmphress commented 1 month ago

We are running Sophos Intercept X Advanced on the server. I also am not seeing any events in the Sophos history.

Did you notice the error I has posted above that I did see during the upgrade run related to the upgrade.php file?

Already on 'master' warning: in the working copy of 'upgrade.php', LF will be replaced by CRLF the next time Git touches it error: unable to create file upgrade.php: Permission denied

snipe commented 1 month ago

@TUmphress thanks for that additional info. We did see that, and we suspect some Windows users might be having a harder time than usual because of the LF/CLRF issue, but it's still bizarre that it would just flat-out delete the file.

TUmphress commented 1 month ago

I would be happy to jump on a web meeting/screen share at some point if that would help. Maybe after/when the next version is released. I am in the USA, Central Time zone.

TShiremanLCOG commented 1 month ago

Here to also confirm that the issue does occur on Windows Server. Non-containerized environment. I am using a different anti-virus as well than the two mentioned. I have also just downloaded a copy of upgrade.php and ran that to successfully update the app.

CopperHusky6475 commented 1 month ago

downloading the upgrade.php didn't work from me, but using "git checkout upgrade.php" did.

iamjustingraves commented 3 weeks ago

Attempting to update to 7.0.11. Upgrade.php had been deleted from getting 7.0.9 to apply. Did a git checkout upgrade.php, and attempted to run php upgrade.php. The script starts but immediately ends.

uberbrady commented 3 weeks ago

Well, we have a separate issue about how the upgrade.php script has been causing trouble for Windows users - at #15240 . I have a PR up to fix that.

But this thing - this is weird. When the upgrade.php script is gone what does git status say? It should say that it's missing, and you should be able to do git checkout upgrade.php and it should be replaced.

But I can't for the life of me figure out what could possibly be deleting it. That's SO WEIRD. We definitely don't delete it ourselves, for certain.

iamjustingraves commented 3 weeks ago

@uberbrady Git Status tells me "On branch master. Your brand is up to date with 'origin/master'. nothing to commit, working tree clean"

I can do a git checkout upgrade.php but when I run php upgrade.php, the script just stops.

image

snipe commented 3 weeks ago

We just merged some updates to the upgrade.php file - can you try again?

iamjustingraves commented 3 weeks ago

Tried again and php upgrade.php ran successfully this time. The php check that hadn't been working also completed and a bunch of dated items were updated along the way during the execution.

snipe commented 3 weeks ago

@iamjustingraves excellent, ty for that feedback. I think we still have a few final touches and polish, but this seems like it’s at least solving some issues.

brianhoganm commented 3 weeks ago

It also worked for me as well. But I needed to do that skip command cuz of curl thing. Thanks!!

On Wed, Aug 21, 2024, 9:51 AM snipe @.***> wrote:

@iamjustingraves https://github.com/iamjustingraves excellent, ty for that feedback. I think we still have a few final touches and polish, but this seems like it’s at least solving some issues.

— Reply to this email directly, view it on GitHub https://github.com/snipe/snipe-it/issues/15200#issuecomment-2302246173, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2FP6U7G7G7456DTXV4EP43ZSSSPXAVCNFSM6AAAAABLZEHRJCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBSGI2DMMJXGM . You are receiving this because you commented.Message ID: @.***>

jsdoptel commented 3 weeks ago

Hello!

On my side, to do it quickly, I did a git checkout upgrade.php to get back my file and copy paste all the codes from the new upgrade.php version and now its work well when I did php upgrade.php!

Thanks @snipe

TUmphress commented 2 weeks ago

To close the loop on my issue, it is now working for me as well. Thanks for the work/help to all involved. I ran the following and was successfully upgraded to 7.11, and the upgrade.php file did not get deleted this time. I ran the checkout to get the missing upgrade.php file back. Shouldn't have to do this step in the future.

git checkout upgrade.php
git pull
php upgrade.php