cannot copy application into /Applications folder

Hi


I am using from a C++ application the following bash command


cp -r MyApp.app /Applications


but no file is copied into /Application folder. This happens on macOS Catalina, but not on older OSs


thanks

Bogdan

On Catalina, you will have to use the Finder to copy an app into Applications or use the data volume path.

On Catalina, you will have to use the Finder to copy an app into Applications or use the data volume path.

What makes you say that? I’m able to copy things to

/Applications/
from Terminal just fine:
$ cp -R ManOpen.app /Applications 
$ ls -lhd /Applications

Also, the data volume path for

/Applications/
is
/Applications/
. It’s the system applications that were relocated, to
/System/Applications/
:
$ ls -lh /System/Applications 
total 0
drwxr-xr-x   3 root  wheel    96B Sep 13 23:06 App Store.app
…

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

First up, I recommend that you not copy applications by shelling out to

cp
. Rather, you should use an API for this. The best API for this is
NSFileManager
, but if you want to avoid Objective-C / Swift then
copyfile
is just fine. See its man page for details.

IMPORTANT If you continue using

cp
, use the
-R
flag. The
-r
flag will break the app if it contains any symlinks (I relearnt that lesson the hard way recently)-:

Once you switch to an API, things will either work or you’ll get some sort of error. If it’s the latter, please post info about that error.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

(I am working with Bogdan)


Thanks eskimo! Your suggestion to use the NSFileManager API worked. I used the copyItemAtPath method. 🙂

eskimo wrote:


What makes you say that?

I assumed that the OP was a beginner programmer learning C++ and trying install an app into the Applications folder. I thought an end-user approach using the Finder would be more helpful along with a comment about the data volume that might encourage them to learn more about it.


I'm not entirely sure what jrumo's co-worker relationship to the OP is or why an Objective-C API would work in a C++ program. Perhaps I don't know all the details.


I always thought that /Applications in Catalina was a firmlink to /System/Volumes/Data/Applications on the data volume. I have seen some really interesting re-arragements of system files in Catalina. And I have seen people doing some truly bizzare things with system files. I realize that firmlinks are perfectly useable, but I really would not recommend people engage in command-line operations on this particular path. Either they don't know what they are doing and need to learn the proper way to install apps or they need to fully understand what has changed in Catalina before they start applying hacks.

Your suggestion to use the NSFileManager API worked.

Excellent news.

Oh, and btw, john daniel’s comment about hard coding paths is important. I’ve just posted some advice on how to find these directories on another thread.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thanks John! That's helpful to know.


Btw, the application is written in the Qt framework, and already had some Objective-C code, so it was easy to switch over to the NSFileManager API. 🙂

I guess I was wrong about the beginner assumption then. You are going to have to be really careful using something like Qt. Those open source frameworks are often years behind developments on macOS. If you have a bunch of C++ code that you can't do without, there are better ways to integrate it into a modern app, especially on macOS. iOS is more of a challenge. It is best to stick to Apple's frameworks for Apple's UI.

cannot copy application into /Applications folder
 
 
Q