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

[Bug]: package_info_plus not working in Windows release build when run from network location #1483

Closed
7 tasks done
cybrox opened this issue Jan 30, 2023 · 5 comments · Fixed by #1697 or #1931
Closed
7 tasks done
Labels
bug Something isn't working triage

Comments

@cybrox
Copy link

cybrox commented Jan 30, 2023

Platform

Windows 10

Plugin

package_info_plus

Version

3.0.2

Flutter SDK

3.7.0

Steps to reproduce

  1. Build the example in plus_plugins\packages\package_info_plus\package_info_plus\example with flutter build windows --release
  2. Copy the resulting files from build\windows\runner\Release to a local drive (e.g. C:\test) -> works fine
  3. Copy the resulting files from build\windows\runner\Release to a network drive (e.g. \\COMPANY-PROFILE\Dekstop) -> does not work

The following screenshot shows the actual result. The left app was run from the C:\ drive and the right one was run from a network location. Both use the same files from the same build.
https://i.imgur.com/YGnJDUN.png

When adding the plugin to my own app, I originally did not wrap the calls in try/catch, which yielded me the following exception when running from a network drive: Error 0x8007007a: Der an einen Systemaufruf übergebene Datenbereich ist zu klein. I can't change the language of the network drive but googling it and changing the language on the Microsoft page gives me "The data area passed to a system call is too small", which sounds about right.

Code Sample

No response

Logs

_example app does not output logs_

Flutter Doctor

[√] Flutter (Channel stable, 3.7.0, on Microsoft Windows [Version 10.0.19045.2364], locale de-CH)
    • Flutter version 3.7.0 on channel stable at C:\Flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b06b8b2710 (6 days ago), 2023-01-23 16:55:55 -0800
    • Engine revision b24591ed32
    • Dart version 2.19.0
    • DevTools version 2.20.1

[X] Windows Version (Unable to confirm if installed Windows version is 10 or greater)

[X] Android toolchain - develop for Android devices
    X Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.


[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.4.3)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.4.33205.214
    • Windows 10 SDK version 10.0.22000.0

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).

[√] VS Code (version 1.74.3)
    • VS Code at C:\Users\sgehring\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.58.0

[√] Connected device (1 available)
    • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19045.2364]

[√] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 3 categories.


For Windows Version, `winver` gives `Version 22H2 (Build 19045.2364)`

Checklist before submitting a bug

  • I Google'd a solution and I couldn't find it
  • I searched on StackOverflow for a solution and I couldn't find it
  • I read the README.md file of the plugin
  • I'm using the latest version of the plugin
  • All dependencies are up to date with flutter pub upgrade
  • I did a flutter clean
  • I tried running the example project
@cybrox cybrox added bug Something isn't working triage labels Jan 30, 2023
@mmasdivins
Copy link
Contributor

mmasdivins commented Apr 19, 2023

I have the same issue, any news?
It happens in debug mode too.

@mmasdivins
Copy link
Contributor

mmasdivins commented Apr 19, 2023

I found the problem:
In package_info_plus_windows.dart on

    final info = _FileVersionInfo(Platform.resolvedExecutable);

The Platform.resolvedExecutable if the path is a network location that should return for example:

\\server\test\example.exe

Instead it returns:

UNC\server\test\example.exe

Replacing "UNC" to "\" will solve the issue, but someone with better knowledge should look into it!

@timsneath
Copy link
Contributor

timsneath commented May 8, 2023

I think this is a bug in the Dart SDK.
https://github.com/dart-lang/sdk/blob/6e18b083dd302a4c32bd6c49a50e68f3cea7331a/runtime/bin/file_win.cc#L1060-L1065 removes the leading \\?\, which leaves an invalid file path on Windows in this scenario.

I believe this is intended to convert \\?\c:\temp\test-file.txt to c:\temp\test-file.txt (for reasons that are unclear to me), which at least leaves a valid file path. But for input like \\?\UNC\LOCALHOST\c$\temp\test-file.txt, which is a valid way to express C:\temp\test-file.txt, the code here will return UNC\LOCALHOST\c$\temp\test-file.txt, which is obviously not valid.

Looks like @bkonyi and @aam last touched this code on the Dart VM side.

Edit: changed example from \\.\ to \\?\, which is the URL format that is likely being twiddled per @aam comment below.

@aam
Copy link

aam commented May 8, 2023

\\?\ prefix that highlighted code is attempting to remove is used on Windows to prepend file path strings, that exceed MAX_PATH in length (https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file?redirectedfrom=MSDN#maximum-path-length-limitation)

Not sure where \\.\ comes into picture. I am not sure extent to which Windows UNC paths are supported.

@timsneath
Copy link
Contributor

@aam I filed dart-lang/sdk#52309 to try and add a little more detail.

\\.\ and \\?\ are very similar prefixes. Both could be returned by Windows. I'll edit my earlier comment to try and resolve the confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
4 participants