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

Blessing a volume on MacOS fails under some circumstances #323

Closed
fvarrui opened this issue May 7, 2023 · 10 comments
Closed

Blessing a volume on MacOS fails under some circumstances #323

fvarrui opened this issue May 7, 2023 · 10 comments
Labels
bug Something isn't working fixed Issue fixed and release pending merged Changes merged into devel branch

Comments

@fvarrui
Copy link
Owner

fvarrui commented May 7, 2023

I tried the snapshot ad it almost works, except for this (in the meantime I moved to Apple Silicon):

Executing command: /bin/sh -c cd '/Users/andrea/Projects/firmasmartcardagent/.' && 'bless' --folder /Volumes/AgentFirma --openfolder /Volumes/AgentFirma
       bless: The 'openfolder' is not supported on Apple Silicon devices.
   DMG image generation failed due to: Command execution failed: bless --folder /Volumes/AgentFirma --openfolder /Volumes/AgentFirma
org.codehaus.plexus.util.cli.CommandLineException: Command execution failed: bless --folder /Volumes/AgentFirma --openfolder /Volumes/AgentFirma
   at io.github.fvarrui.javapackager.utils.CommandUtils.executeOnDirectory(CommandUtils.java:20)
   at io.github.fvarrui.javapackager.utils.CommandUtils.execute(CommandUtils.java:30)
   at io.github.fvarrui.javapackager.packagers.GenerateDmg.doApply(GenerateDmg.java:137)
   at io.github.fvarrui.javapackager.packagers.GenerateDmg.doApply(GenerateDmg.java:22)
   at io.github.fvarrui.javapackager.packagers.ArtifactGenerator.apply(ArtifactGenerator.java:44)
   at io.github.fvarrui.javapackager.packagers.Packager.generateInstallers(Packager.java:440)
   at io.github.fvarrui.javapackager.gradle.AbstractPackageTask.doPackage(AbstractPackageTask.java:46)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:498)
   at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:125)
   at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:58)
   at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:51)
   at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:29)
   at org.gradle.api.internal.tasks.execution.TaskExecution$3.run(TaskExecution.java:242)
   at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
   at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
   at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
   at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
   at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
   at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
   at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)
   at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:68)
   at org.gradle.api.internal.tasks.execution.TaskExecution.executeAction(TaskExecution.java:227)
   at org.gradle.api.internal.tasks.execution.TaskExecution.executeActions(TaskExecution.java:210)
   at org.gradle.api.internal.tasks.execution.TaskExecution.executeWithPreviousOutputFiles(TaskExecution.java:193)
   at org.gradle.api.internal.tasks.execution.TaskExecution.execute(TaskExecution.java:166)
   at org.gradle.internal.execution.steps.ExecuteStep.executeInternal(ExecuteStep.java:105)
   at org.gradle.internal.execution.steps.ExecuteStep.access$000(ExecuteStep.java:44)
   at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:59)
   at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:56)
   at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
   at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
   at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
   at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
   at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
   at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
   at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
   at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
   at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:56)
   at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:44)
   at org.gradle.internal.execution.steps.RemovePreviousOutputsStep.execute(RemovePreviousOutputsStep.java:67)
   at org.gradle.internal.execution.steps.RemovePreviousOutputsStep.execute(RemovePreviousOutputsStep.java:37)
   at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:41)
   at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:74)
   at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:55)
   at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:50)
   at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:28)
   at org.gradle.internal.execution.steps.CaptureStateAfterExecutionStep.executeDelegateBroadcastingChanges(CaptureStateAfterExecutionStep.java:100)
   at org.gradle.internal.execution.steps.CaptureStateAfterExecutionStep.execute(CaptureStateAfterExecutionStep.java:72)
   at org.gradle.internal.execution.steps.CaptureStateAfterExecutionStep.execute(CaptureStateAfterExecutionStep.java:50)
   at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:40)
   at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:29)
   at org.gradle.internal.execution.steps.BuildCacheStep.executeWithoutCache(BuildCacheStep.java:166)
   at org.gradle.internal.execution.steps.BuildCacheStep.lambda$execute$1(BuildCacheStep.java:70)
   at org.gradle.internal.Either$Right.fold(Either.java:175)
   at org.gradle.internal.execution.caching.CachingState.fold(CachingState.java:59)
   at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:68)
   at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:46)
   at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:36)
   at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:25)
   at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:36)
   at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:22)
   at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:91)
   at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$2(SkipUpToDateStep.java:55)
   at java.util.Optional.orElseGet(Optional.java:267)
   at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:55)
   at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:37)
   at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:65)
   at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:36)
   at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:37)
   at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:27)
   at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:76)
   at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:37)
   at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:94)
   at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:49)
   at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:71)
   at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:45)
   at org.gradle.internal.execution.steps.SkipEmptyWorkStep.executeWithNonEmptySources(SkipEmptyWorkStep.java:177)
   at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:81)
   at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:53)
   at org.gradle.internal.execution.steps.RemoveUntrackedExecutionStateStep.execute(RemoveUntrackedExecutionStateStep.java:32)
   at org.gradle.internal.execution.steps.RemoveUntrackedExecutionStateStep.execute(RemoveUntrackedExecutionStateStep.java:21)
   at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsStartedStep.execute(MarkSnapshottingInputsStartedStep.java:38)
   at org.gradle.internal.execution.steps.LoadPreviousExecutionStateStep.execute(LoadPreviousExecutionStateStep.java:36)
   at org.gradle.internal.execution.steps.LoadPreviousExecutionStateStep.execute(LoadPreviousExecutionStateStep.java:23)
   at org.gradle.internal.execution.steps.CleanupStaleOutputsStep.execute(CleanupStaleOutputsStep.java:75)
   at org.gradle.internal.execution.steps.CleanupStaleOutputsStep.execute(CleanupStaleOutputsStep.java:41)
   at org.gradle.internal.execution.steps.AssignWorkspaceStep.lambda$execute$0(AssignWorkspaceStep.java:32)
   at org.gradle.api.internal.tasks.execution.TaskExecution$4.withWorkspace(TaskExecution.java:287)
   at org.gradle.internal.execution.steps.AssignWorkspaceStep.execute(AssignWorkspaceStep.java:30)
   at org.gradle.internal.execution.steps.AssignWorkspaceStep.execute(AssignWorkspaceStep.java:21)
   at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:37)
   at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:27)
   at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:47)
   at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:34)
   at org.gradle.internal.execution.impl.DefaultExecutionEngine$1.execute(DefaultExecutionEngine.java:64)
   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:146)
   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:135)
   at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
   at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:51)
   at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
   at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:74)
   at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
   at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
   at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
   at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
   at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
   at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
   at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
   at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
   at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
   at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
   at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
   at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
   at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
   at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:42)
   at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:337)
   at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:324)
   at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:317)
   at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:303)
   at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:463)
   at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:380)
   at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
   at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:49)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
   at java.lang.Thread.run(Thread.java:748)

Originally posted by @amariottini in #315 (comment)

@fvarrui fvarrui added the bug Something isn't working label May 7, 2023
@fvarrui
Copy link
Owner Author

fvarrui commented May 7, 2023

It seems that something has changed in bless command for M1 devices. If architecture is x64 we can use: bless --folder /Volumes/AgentFirma --openfolder /Volumes/AgentFirma, but for ARM64 we omit this command execution.

Next code gets system architecture and check if it's equal to aarch64.

String osArchitecture = System.getProperty("os.arch");
boolean isAarch64 = osArchitecture.toLowerCase().equals("aarch64");

And then blessing the app's folder is skipped if your architecture is ARM64:

if (!isAarch64) {
// makes the top window open itself on mount:
Logger.info("Blessing ...");
execute("bless", "--folder", mountFolder, "--openfolder", mountFolder);
}

The problem is that if using an Apple Silicon architecture with a x86_64 JDK (which is possible thanks to Rosetta 2), when determining the architecture from Java it's returning that of the JDK, not that of the OS (info link here), so is getting x86_64 when it should be aarch64, then try to run bless command and the building process fails.

A simple fix has been implemented: have the process continue even if the blessing fails, reporting the exception as warning

@fvarrui
Copy link
Owner Author

fvarrui commented May 7, 2023

Path applied in devel branch:

if (!isAarch64) {
// makes the top window open itself on mount:
Logger.info("Blessing ...");
try {
execute("bless", "--folder", mountFolder, "--openfolder", mountFolder); }
catch (Exception e){
Logger.warn("Error blessing " + mountFolder + " due to: " + e.getMessage());
}
}

@fvarrui
Copy link
Owner Author

fvarrui commented May 7, 2023

Ready to be released in JP 1.7.3 ... @amariottini please, give some feedback to confirm this fix is working for you (JP 1.7.3-20230505.163915-1 SNAPSHOT version).

@fvarrui fvarrui added the feedback Waiting for feedback label May 7, 2023
@amariottini
Copy link

Yes it works, I prints
bless: The 'openfolder' is not supported on Apple Silicon devices.
but it doesn't stop with an error.

@fvarrui
Copy link
Owner Author

fvarrui commented May 8, 2023

Yes it works, I prints bless: The 'openfolder' is not supported on Apple Silicon devices. but it doesn't stop with an error.

I guess that the generated DMG is working fine

@amariottini
Copy link

Yes, at least on Apple Silicon.
I'll try on Intel and let you know.

@amariottini
Copy link

I tried the image even on Intel and it works.

@amariottini
Copy link

Any news on the release of v 1.7.3?

@fvarrui
Copy link
Owner Author

fvarrui commented May 23, 2023

I hope sooner than later 😅

@fvarrui fvarrui added fixed Issue fixed and release pending and removed feedback Waiting for feedback labels May 23, 2023
@fvarrui fvarrui added the merged Changes merged into devel branch label Aug 11, 2023
@fvarrui
Copy link
Owner Author

fvarrui commented Aug 11, 2023

1.7.3 released to Maven Central

@fvarrui fvarrui closed this as completed Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed Issue fixed and release pending merged Changes merged into devel branch
Projects
None yet
Development

No branches or pull requests

2 participants