dub icon indicating copy to clipboard operation
dub copied to clipboard

`dub run` with targetType none fails with assert error instead of proper error message

Open MrcSnm opened this issue 2 years ago • 10 comments
trafficstars

System information

  • dub version: 1.31.1
  • OS Platform and distribution: MacOS 12.6 Monterey
  • compiler version: 2.102.1

Bug Description

I'm trying to pull my libraries using targetType none, but on macOS I get the following error:

core.exception.AssertError@source/dub/compilers/dmd.d(303): No target name set.

How to reproduce?

"name": "hipremeengine_ios",
	"authors": [
		"Marcelo Silva"
	],
	"targetType": "library",
	"targetPath": "libs",
	"copyright": "Copyright © 2023, Marcelo Silva",
	"dependencies": {
		"metal": {"path": "/Users/marcelosilva/Desktop/D/HipremeEngine/dependencies/metal/"}
	},

	"configurations": [
		{
			"name": "dependencies",
			"targetType": "none",
			"targetName": "metal",
			"postBuildCommands": [
				"cp /Users/marcelosilva/Desktop/D/HipremeEngine/dependencies/metal/libmetal.a libs"
			]
		}
	],
	"postBuildCommands": [
		"dub build -c dependencies"
	]

Expected Behavior

Logs

MrcSnm avatar Mar 08 '23 11:03 MrcSnm

please run dub with -v and post the log of what it prints out. Also are you on ARM? is this a problem with Just DMD, or are LDC/GDC also affected?

thewilsonator avatar Mar 08 '23 12:03 thewilsonator

I'm only using DMD since I'm also using Objective-C externs. No, this is X86_64 for the while.

MrcSnm avatar Mar 08 '23 12:03 MrcSnm

% dub -v 
Using dub registry url 'https://code.dlang.org/'
Note: Failed to determine version of package hipremeengine_ios at .. Assuming ~master.
  Version selection for dependency metal (metal) of hipremeengine_ios is missing.
  Adding local metal in /Users/marcelosilva/Desktop/D/HipremeEngine/dependencies/metal/
Note: Failed to determine version of package metal at .. Assuming ~master.
  Found dependency metal @/Users/marcelosilva/Desktop/D/HipremeEngine/dependencies/metal/
Generating using build
Configuring dependent hipremeengine_ios, deps:"metal"
  Configuring dependent metal, deps:
    Starting Performing "debug" build using /Library/D/dmd/bin/dmd for x86_64.
  Up-to-date metal ~master: target for configuration [library] is up to date.
Using existing build in /Users/marcelosilva/.dub/cache/metal/~master/build/library-debug-posix.osx.darwin-x86_64-dmd_v2.102.1-0437653A81EAACC825247ECE9DD324ABF203C6A6DD1A93C74913A78676C26629.
Copying target from /Users/marcelosilva/.dub/cache/metal/~master/build/library-debug-posix.osx.darwin-x86_64-dmd_v2.102.1-0437653A81EAACC825247ECE9DD324ABF203C6A6DD1A93C74913A78676C26629/libmetal.a to /Users/marcelosilva/Desktop/D/HipremeEngine/dependencies/metal
    Finished To force a rebuild of up-to-date targets, run again with --force
core.exception.AssertError@source/dub/compilers/dmd.d(303): No target name set.
----------------
??:? _d_assert_msg [0x10653ad1f]
??:? const immutable(char)[] dub.compilers.dmd.DMDCompiler.getTargetFileName(in dub.compilers.buildsettings.BuildSettings, in dub.platform.BuildPlatform) [0x10627159b]
??:? void dub.generators.build.BuildGenerator.performPostGenerateActions(dub.generators.generator.GeneratorSettings, in dub.generators.generator.ProjectGenerator.TargetInfo[immutable(char)[]]) [0x10622fb08]
??:? void dub.generators.generator.ProjectGenerator.generate(dub.generators.generator.GeneratorSettings) [0x105fb8dd9]
??:? int dub.commandline.GenerateCommand.execute(dub.dub.Dub, immutable(char)[][], immutable(char)[][]) [0x1063fad98]
??:? int dub.commandline.RunCommand.execute(dub.dub.Dub, immutable(char)[][], immutable(char)[][]) [0x1063fbdfd]
??:? int dub.commandline.runDubCommandLine(immutable(char)[][]) [0x1063f3480]
??:? void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).runAll() [0x1065666d7]
??:? _d_run_main2 [0x1065664c1]
??:? _d_run_main [0x10656631c]

MrcSnm avatar Mar 08 '23 12:03 MrcSnm

can't reproduce on linux with an empty dependency, e.g.

{
        "name": "test",
        "targetType": "library",
        "targetPath": "libs",
        "dependencies": {
                "b": {"path":"b"}
        },
        "configurations": [
                {
                        "name": "dependencies",
                        "targetType": "none",
                        "targetName": "metal",
                        "postBuildCommands": [
                                "echo foo"
                        ]
                }
        ],
        "postBuildCommands": [
                "dub build -c dependencies"
        ]
}
  • mkdir b; cd b; dub init -n; echo "module lib" > source/lib.d

WebFreak001 avatar Mar 08 '23 15:03 WebFreak001

can you try to see if that works or breaks on macOS?

WebFreak001 avatar Mar 08 '23 15:03 WebFreak001

I have tested with your thing but it worked 🤔 I'll send a zip because I was able to create a minimal project that broke here

MrcSnm avatar Mar 08 '23 15:03 MrcSnm

Test.zip

There it is

MrcSnm avatar Mar 08 '23 15:03 MrcSnm

ok seems like this only happens in debug builds of dub, also to test locally with custom dub, change the postBuildCommand from "dub ... to "$DUB ... (you should also use $DUB in general in published packages to run dub)

Stacktrace:

$ ~/dev/dub/bin/dub build
    Starting Performing "debug" build using dmd for x86_64.
    Building proja ~master: building configuration [main]
  Post-build Running commands
    Starting Performing "debug" build using dmd for x86_64.
    Building projb ~master: building configuration [library]
core.exception.AssertError@source/dub/compilers/dmd.d(303): No target name set.
----------------
??:? _d_assert_msg [0x555aa212acdc]
source/dub/compilers/dmd.d:303 const immutable(char)[] dub.compilers.dmd.DMDCompiler.getTargetFileName(in dub.compilers.buildsettings.BuildSettings, in dub.platform.BuildPlatform) [0x555aa1e728ba]
source/dub/generators/build.d:708 dub.internal.vibecompat.inet.path.NativePath dub.generators.build.getTargetPath(scope ref const(dub.compilers.buildsettings.BuildSettings), ref const(dub.generators.generator.GeneratorSettings)) [0x555aa1eaeb40]
source/dub/generators/build.d:195 void dub.generators.build.BuildGenerator.performPostGenerateActions(dub.generators.generator.GeneratorSettings, in dub.generators.generator.ProjectGenerator.TargetInfo[immutable(char)[]]) [0x555aa1ea973b]
source/dub/generators/generator.d:200 void dub.generators.generator.ProjectGenerator.generate(dub.generators.generator.GeneratorSettings) [0x555aa1eb3988]
source/dub/dub.d:700 void dub.dub.Dub.generateProject(immutable(char)[], dub.generators.generator.GeneratorSettings) [0x555aa1e9b24e]
source/dub/commandline.d:1218 int dub.commandline.GenerateCommand.execute(dub.dub.Dub, immutable(char)[][], immutable(char)[][]) [0x555aa1cbad38]
source/dub/commandline.d:1266 int dub.commandline.BuildCommand.execute(dub.dub.Dub, immutable(char)[][], immutable(char)[][]) [0x555aa1cbb1b2]
source/dub/commandline.d:1356 int dub.commandline.RunCommand.execute(dub.dub.Dub, immutable(char)[][], immutable(char)[][]) [0x555aa1cbb8f6]
source/dub/commandline.d:496 int dub.commandline.runDubCommandLine(immutable(char)[][]) [0x555aa1cb68bb]
source/app.d:26 _Dmain [0x555aa1c9b2e7]
Error Command failed with exit code 1: /home/webfreak/dev/dub/bin/dub -c dependencies

WebFreak001 avatar Mar 08 '23 15:03 WebFreak001

Debug build of dmd? I tried to change from dub to $DUB but I still get this error

MrcSnm avatar Mar 08 '23 16:03 MrcSnm

sorry, I meant debug builds of dub

WebFreak001 avatar Mar 08 '23 16:03 WebFreak001