Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intermittent Paket.Restore.props error in 5.181.1 - Index was outside the bounds of the array #3404

Closed
yaakov-h opened this issue Oct 30, 2018 · 20 comments

Comments

@yaakov-h
Copy link
Contributor

yaakov-h commented Oct 30, 2018

Description

After upgrading Paket to 5.181.1 from 5.173.1 I get an intermittent build error in Paket.Restore.props.

Repro steps

  1. Run .paket\paket.exe restore
  2. Run dotnet.exe restore MyProject.csproj --no-dependencies

Expected behavior

Packages are restored

Actual behavior

 Checking Paket version (version 5.181.1 requested)...
  Paket.exe 5.181.1 is up to date.
  Paket version 5.181.1
  The last restore is still up to date. Nothing left to do.
  Performance:
   - Runtime: 104 milliseconds
C:\path\to\project\.paket\Paket.Restore.targets(147,5): error MSB4184: The expression ""System.String[]".GetValue(5)" cannot be evaluated. Index was outside the bounds of the array. 

Known workarounds

Delete all un-source-controlled files and rebuild.

@yaakov-h
Copy link
Contributor Author

yaakov-h commented Oct 30, 2018

On further investigation this appears to be caused by having paket files from 5.173.1 lying around when running the 5.181.1 restore process. If I scorch the project (tfpt scorch) then it builds fine.

@yaakov-h
Copy link
Contributor Author

It seems to be reliably trigger-able by a dirty workspace.

In my case, Project\obj\Project.csproj.netstandard2.0.paket.resolved, Project\obj\Project.csproj.net46.paket.resolved and similar are CSV files with only 5 columns, not 6.

e.g.

Newtonsoft.Json,11.0.2,Transitive,Main,false
Microsoft.AspNet.WebApi.Client,5.2.6,Direct,Main,false

I assume that either:

  • Paket did not know to invalidate this and recompute this intermediary file, or
  • Paket does know to invalidate and recompute, but does that at some point after the MSBuild parsing runs and crashes.

@j-alexander
Copy link

j-alexander commented Nov 5, 2018

It seems to be reliably trigger-able by a dirty workspace.

In my case, Project\obj\Project.csproj.netstandard2.0.paket.resolved, Project\obj\Project.csproj.net46.paket.resolved and similar are CSV files with only 5 columns, not 6.

Aha! Yes, and running git clean -xdf from the root of my project and running through it again works. I made the mistake of copying the repo from my windows VM and then trying to build in Visual Studio for mac.

@forki
Copy link
Member

forki commented Nov 6, 2018 via email

@yaakov-h
Copy link
Contributor Author

yaakov-h commented Nov 6, 2018

I think I can make a get-or-default fairly easily, but should the default be true, false, or some other behaviour entirely?

@forki
Copy link
Member

forki commented Nov 6, 2018

maybe just make it a nicer error message?

@yaakov-h
Copy link
Contributor Author

yaakov-h commented Nov 6, 2018

“Aaaaaaaah please delete all your obj/ folders and try again”? 🙃

@forki
Copy link
Member

forki commented Nov 6, 2018 via email

@enricosada
Copy link
Collaborator

The paket target file need to add msbuild condition, to check array length after split

<PackageName>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0])</PackageName>

because was trying to load a csv with fewer columns, generated by previous paket version

@yaakov-h
Copy link
Contributor Author

yaakov-h commented Nov 7, 2018

I can't quite make sense of 373c969:

A new column was inserted as the second-last column in the file.
The new column is AllPrivateAssets.
The old column was AllPrivateAssets and is now CopyLocal.

This doesn't leave me with a simple answer to default value.

Can we perhaps force packet.exe to regenerate this intermediary file if the column count is off?

@forki
Copy link
Member

forki commented Nov 7, 2018 via email

@yaakov-h
Copy link
Contributor Author

yaakov-h commented Nov 7, 2018

I'd rather have Paket self-recover than stall and require the user to take action. Particularly because I'd have to manually clean up a lot of obj folders.

Another possible fix:

If there are 5 columns, use old behaviour in props.
If there are 6 columns, use new behaviour in props.

Would you be OK with a bit of back-compat in the props file?

@forki
Copy link
Member

forki commented Nov 7, 2018 via email

@yaakov-h
Copy link
Contributor Author

yaakov-h commented Nov 7, 2018

Git clean -xdf and run build again. It does not matter how many obj you
have.

Try about 80 different TFVC repositories times 40 build servers, and I'd have to clean all serversat the time where paket is upgraded, in each repository. If I clean too early, the old paket will write the old files back out again.

(No, the build servers don't auto-clean between builds yet 😢)

@forki
Copy link
Member

forki commented Nov 7, 2018 via email

@yaakov-h
Copy link
Contributor Author

yaakov-h commented Nov 7, 2018

Possibly, but at the same time, I've never seen a similar tool that requires major intervention on a minor version upgrade. It should be able to either deal with it, or self-heal.

@forki
Copy link
Member

forki commented Nov 7, 2018 via email

@forki forki closed this as completed in 828f9e4 Nov 7, 2018
@forki
Copy link
Member

forki commented Nov 7, 2018

can you please retry with latest - it also comes with slightly changed targets file

@yaakov-h
Copy link
Contributor Author

yaakov-h commented Nov 8, 2018

I retried with 5.186.0, but now Paket doesn't include my dependencies from paket.references. I get build errors about missing classes/namespaces, and the dependencies don't show under the "Dependencies" node in Visual Studio's Solution Explorer.

If I scorch/clean the repository and rebuild, it works, suggesting that some leftover data from the old version is still being (mis-)used.

@matthid
Copy link
Member

matthid commented Nov 11, 2018

I'm not sure this is solved. I'm seeing something similar in the fake release process.

I'd expect that the following scenario works:

  • Restore with an older paket version
  • Continue the build with a newer paket version (consider the user updating the version in paket.dependencies for example)

As the following build shows this scenario is not working:

D:\a\1\s\.paket\Paket.Restore.targets(157,9): error MSB4184: The expression ""System.String[]".GetValue(5)" cannot be evaluated. Index was outside the bounds of the array. [D:\a\1\s\src\app\Fake.Core.Context\Fake.Core.Context.fsproj]

I feel like we need to be much more careful when updating caching files as this scenario is kind of important for fake to work properly together with paket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants