Skip to content

linux run fails with "/usr/local" permissions #115376

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

Open
gaaclarke opened this issue Nov 15, 2022 · 12 comments
Open

linux run fails with "/usr/local" permissions #115376

gaaclarke opened this issue Nov 15, 2022 · 12 comments
Labels
a: first hour The first hour of using Flutter P2 Important issues not at the top of the work list platform-linux Building on or for Linux specifically team-tool Owned by Flutter Tool team tool Affects the "flutter" command-line tool. See also t: labels. triaged-tool Triaged by Flutter Tool team

Comments

@gaaclarke
Copy link
Member

gaaclarke commented Nov 15, 2022

Running "flutter run" on linux can fail because of permissions to "/usr/local". It is surprising that it would make this complaint. The issue was previously reported and closed but not fixed. I'm making a new issue.

Error log

clarkeaa@gamer:~/dev/flutter-examples/counter$ flutter run
Launching lib/main.dart on Linux in debug mode...
CMake Error at cmake_install.cmake:66 (file):
  file INSTALL cannot copy file
  "/home/clarkeaa/dev/flutter-examples/counter/build/linux/x64/debug/intermediates_do_not_run/counter"
  to "/usr/local/counter": Permission denied.

Flutter doctor

[✓] Flutter (Channel stable, 3.3.8, on Ubuntu 22.04.1 LTS 5.15.68.1-microsoft-standard-WSL2, locale C.UTF-8)
    • Flutter version 3.3.8 on channel stable at /home/clarkeaa/dev/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 52b3dc25f6 (7 days ago), 2022-11-09 12:09:26 +0800
    • Engine revision 857bd6b74c
    • Dart version 2.18.4
    • DevTools version 2.15.0

[✓] Linux toolchain - develop for Linux desktop
    • Ubuntu clang version 14.0.0-1ubuntu1
    • cmake version 3.22.1
    • ninja version 1.10.1
    • pkg-config version 0.29.2

Environment

Ubuntu 22.04.1 LTS on Windows Linux Subsystem

Previously reported workaround

run flutter clean and try again

Previously closed issue

#59890

@gaaclarke gaaclarke added the platform-linux Building on or for Linux specifically label Nov 15, 2022
@stuartmorgan-g
Copy link
Contributor

Are you able to reproduce it? It's been closed a number of times because nobody who sees it can ever reproduce it more than once. My working theory is that it's a CMake bug.

@stuartmorgan-g
Copy link
Contributor

This is my previous summary of the issue: #73881 (comment)

@gaaclarke
Copy link
Member Author

Are you able to reproduce it? It's been closed a number of times because nobody who sees it can ever reproduce it more than once. My working theory is that it's a CMake bug.

I deleted that project, created a new one and the permissions problem didn't show up again. I'm not sure what is being cached where that causes it to behave differently.

The problem with this bug is that it affects first time user experience which isn't good.

@danagbemava-nc danagbemava-nc added tool Affects the "flutter" command-line tool. See also t: labels. a: first hour The first hour of using Flutter labels Nov 16, 2022
@ZimboPro
Copy link

The issue was happening consistently for me, I managed to fix the issue by doing the following in linux/CMakeLists.txt

set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
  set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
endif()

to

set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)

More info can be found in the linked issue above.

@shassard
Copy link

I ran into this issue with a fresh manual install of flutter 3.10.5 on void linux when creating a new project without all of the required build dependencies installed (no cmake, ninja, gtk+) and then attempting a build which fails, then installing all the dependencies. The project was broken at this point, but creating a new project even after removing all the dependencies and trying to reproduce the issue didn't result in a repro.

@flutter-triage-bot flutter-triage-bot bot added the team-tool Owned by Flutter Tool team label Jul 8, 2023
@christopherfujino christopherfujino added P2 Important issues not at the top of the work list triaged-tool Triaged by Flutter Tool team labels Jul 15, 2023
@cathino
Copy link

cathino commented Dec 18, 2023

I run the command: flutter run -d linux, and got error:

Launching lib/main.dart on Linux in debug mode...
CMake Error at cmake_install.cmake:66 (file):
  file INSTALL cannot copy file
  "/media/xxx/flutter/xxx/build/linux/x64/debug/intermediates_do_not_run/xxx"
  to "/usr/local/xxx": Permission denied.


Building Linux application...                                           
Exception: Build process failed

Flutter version is: 3.16.3.

After using @ZimboPro 's method, it works:

The issue was happening consistently for me, I managed to fix the issue by doing the following in linux/CMakeLists.txt

set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
  set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
endif()

to

set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)

More info can be found in the linked issue above.

@pavlov061356
Copy link

The issue was happening consistently for me, I managed to fix the issue by doing the following in linux/CMakeLists.txt

set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
  set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
endif()

to

set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)

More info can be found in the linked issue above.

That worked for me, thx

@lomby92
Copy link

lomby92 commented Mar 14, 2024

Environment

OS: Fedora Linux 38 (Sway) x86_64
Kernel: 6.7.9-100.fc38.x86_64

Flutter

Flutter 3.19.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 7482962148 (2 settimane fa) • 2024-02-27 16:51:22 -0500
Engine • revision 04817c99c9
Tools • Dart 3.3.0 • DevTools 2.31.1

I run flutter clean and it fixed the error

cdawei added a commit to anusii/solidpod that referenced this issue Jun 27, 2024
Harry-Chen added a commit to canokeys/canokey-console that referenced this issue Jan 13, 2025
Signed-off-by: Shengqi Chen <harry-chen@outlook.com>
@CharleeSF
Copy link

I had the same issue, but like @shassard suggests, it was most likely caused by attempting to build without having all system dependencies met.

Installing dependencies and doing flutter clean solved the issue for me.

@xausky
Copy link

xausky commented May 13, 2025

I seem to have found a possible reason. I am using Flutter version 3.22.3 to build a project that depends on media_kit. On Ubuntu, if the libmpv-dev dependency is not installed in advance, it will give an error: CMake Error at /usr/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:230 (message): Could NOT find ALSA (missing: ALSA_LIBRARY ALSA_INCLUDE_DIR). After I installed libmpv-dev, running flutter build linux triggered this problem: Permission denied to "/usr/local/counter". I have to run flutter clean and then flutter build linux to resolve it.

@oliver-hrkltz
Copy link

oliver-hrkltz commented May 16, 2025

I had the same issue today on a new Debian setup. First I did the build with a missing lib (libgtk-3-dev) and after adding the lib and rebuild I had the issue mentioned in this topic:

user@Debian:~/Development/my_app$ flutter run -d Linux
Launching lib/main.dart on Linux in debug mode...
CMake Error at cmake_install.cmake:66 (file):
  file INSTALL cannot copy file
  "/home/user/Development/my_app/build/linux/x64/debug/intermediates_do_not_run/my_app"
  to "/usr/local/my_app": Permission denied.


Building Linux application...                                           
Error: Build process failed

After doing flutter clean I could compile this project without errors and as expected.

P.S. [✓] Flutter (Channel stable, 3.29.3, on Debian GNU/Linux 12 (bookworm) 6.1.0-34-cloud-amd64, locale en_US.UTF-8)

@YousefAK009
Copy link

The issue was happening consistently for me, I managed to fix the issue by doing the following in linux/CMakeLists.txt

set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
endif()
to

set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
More info can be found in the linked issue above.

worked for me. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: first hour The first hour of using Flutter P2 Important issues not at the top of the work list platform-linux Building on or for Linux specifically team-tool Owned by Flutter Tool team tool Affects the "flutter" command-line tool. See also t: labels. triaged-tool Triaged by Flutter Tool team
Projects
None yet
Development

No branches or pull requests

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy