Skip to content

[BUG] Error: PathNotFoundException during symbolic link resolution on Linux (/proc/self/exe not found) #162063

Description

@soufianebenyaala

Steps to reproduce

  1. Run the Flutter application on a Linux device.
  2. Observe the error during startup.

Expected results

The application should start without errors, and the path_provider_linux package should successfully resolve symbolic links for the application support path.

Actual results

PathNotFoundException: Cannot resolve symbolic links, path = '/proc/self/exe' (OS Error: No such file or directory, errno = 2)

Code sample

Code sample
Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await init(); // Injection container initialization
  runApp(MyApp());
}

init(){
    final prefsWithCache = await SharedPreferencesWithCache.create(
    cacheOptions: const SharedPreferencesWithCacheOptions(),
  );
  /// Register AppPreferences and its implementation
  di.registerLazySingleton<AppPreferences>(
    () => AppPreferencesImpl(
      prefsWithCache,
    ),
  );
}

class AppPreferencesImpl implements AppPreferences {
  late SharedPreferencesWithCache _sharedPreferences;

  set sharedPreferences(SharedPreferencesWithCache value) {
    _sharedPreferences = value;
  }

  AppPreferencesImpl(SharedPreferencesWithCache sharedPrefs) {
    _sharedPreferences = sharedPrefs;
    initSharedPrefs();
  }

  initSharedPrefs() async {
    _sharedPreferences = await SharedPreferencesWithCache.create(
      cacheOptions: const SharedPreferencesWithCacheOptions(),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

Image

Logs

Logs
(innogec_mobile:161765): GLib-GObject-WARNING **: 09:28:46.135: g_object_weak_unref: couldn't find weak ref 0x75a497ff0b50(0x29c234d8)
Restarted application in 684ms.
[ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: PathNotFoundException: Cannot resolve symbolic links, path = '/proc/self/exe' (OS Error: No such file or directory, errno = 2)
#0      _checkForErrorResponse (dart:io/common.dart:56:9)
common.dart:56
#1      FileSystemEntity.resolveSymbolicLinks.<anonymous closure> (dart:io/file_system_entity.dart:318:7)
file_system_entity.dart:318
<asynchronous suspension>
#2      PathProviderLinux._getExecutableName (package:path_provider_linux/src/path_provider_linux.dart:92:9)
path_provider_linux.dart:92
<asynchronous suspension>
#3      PathProviderLinux._getId (package:path_provider_linux/src/path_provider_linux.dart:100:30)
path_provider_linux.dart:100
<asynchronous suspension>
#4      PathProviderLinux.getApplicationSupportPath (package:path_provider_linux/src/path_provider_linux.dart:51:48)
path_provider_linux.dart:51
<asynchronous suspension>
#5      _getLocalDataFile (package:shared_preferences_linux/shared_preferences_linux.dart:339:29)
shared_preferences_linux.dart:339
<asynchronous suspension>
#6      _reload (package:shared_preferences_linux/shared_preferences_linux.dart:354:31)
shared_preferences_linux.dart:354
<asynchronous suspension>
#7      SharedPreferencesAsyncLinux._readPreferences (package:shared_preferences_linux/shared_preferences_linux.dart:323:28)
shared_preferences_linux.dart:323
<asynchronous suspension>
#8      SharedPreferencesAsyncLinux._readAll (package:shared_preferences_linux/shared_preferences_linux.dart:300:34)
shared_preferences_linux.dart:300
<asynchronous suspension>
#9      SharedPreferencesWithCache.reloadCache (package:shared_preferences/src/shared_preferences_async.dart:225:9)
shared_preferences_async.dart:225
<asynchronous suspension>
#10     SharedPreferencesWithCache.create (package:shared_preferences/src/shared_preferences_async.dart:200:5)
shared_preferences_async.dart:200
<asynchronous suspension>
#11     init (package:innogec_mobile/injection_container.dart:58:26)
injection_container.dart:58
<asynchronous suspension>
#12     mainCommon (package:innogec_mobile/main_common.dart:16:3)
main_common.dart:16
<asynchronous suspension>

Flutter Doctor output

Doctor output
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /home/user/Android/Sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: /snap/android-studio/161/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.10+0-17.0.10b1087.21-11609105)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 10.0.0-4ubuntu1
    • cmake version 3.16.3
    • ninja version 1.10.0
    • pkg-config version 0.29.1

[✓] Android Studio (version 2023.3)
    • Android Studio at /snap/android-studio/157
    • Flutter plugin version 79.0.2
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      17.0.10+0-17.0.10b1087.21-11572160)

[✓] Android Studio (version 2024.1)
    • Android Studio at /snap/android-studio/161
    • Flutter plugin version 83.0.2
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      17.0.10+0-17.0.10b1087.21-11609105)

[✓] IntelliJ IDEA Ultimate Edition (version 2024.3)
    • IntelliJ at /snap/intellij-idea-ultimate/561
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.96.4)
    • VS Code at /snap/code/current/usr/share/code
    • Flutter extension version 3.102.0

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Ubuntu 22.04.5 LTS
      6.8.0-51-generic
    • Chrome (web)    • chrome • web-javascript • Google Chrome 132.0.6834.83

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    in triagePresently being triaged by the triage teamwaiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions