Repository navigation
Type generation fails #617
Copy link
Copy link
Open
Description
Sorry if this is a stupid question but, when I init the type generation fails, im not sure why
ags init
error: type generation failed, try running
/usr/bin/npx -y @ts-for-gir/cli@4.0.0-beta.15 generate * --ignoreVersionConflicts --outdir /home/yash/.config/ags/@girs -g /usr/local/share/gir-1.0 -g /usr/share/gir-1.0 -g /usr/share/*/gir-1.0 -g gir-1.0
When I try the recommended command it gives me the following error
/usr/bin/npx -y @ts-for-gir/cli@4.0.0-beta.15 generate * --ignoreVersionConflicts --outdir /home/yash/.config/ags/@girs -g /usr/local/share/gir-1.0 -g /usr/share/gir-1.0 -g /usr/share/*/gir-1.0 -g gir-1.0
Adding generics...
ts-for-gir generate [modules..]
Generates Typescript type definition .d.ts files from GIR for GJS
Options:
--version Show version number [boolean]
--help Show help [boolean]
--modules GIR modules to load, e.g. 'Gio-2.0'. Accepts mul
tiple modules [array] [default: ["*"]]
-g, --girDirectories GIR directories
[array] [default: ["/usr/local/share/gir-1.0","/usr/share/gir-1.0","/usr/share
/*/gir-1.0","/usr/share/gnome-shell","/usr/share/gnome-shell/gir-1.0","/usr/li
b64/mutter-*","/usr/lib/mutter-*","/usr/lib/x86_64-linux-gnu/mutter-*"]]
--root Root directory of your project
[string] [default: "/home/yash/.config"]
-o, --outdir Directory to output to
[string] [default: "./@types"]
-i, --ignore Modules that should be ignored
[array] [default: []]
-v, --verbose Switch on/off the verbose mode
[string] [default: false]
--ignoreVersionConflicts Skip prompts for library version selection when
multiple versions are detected
[string] [default: false]
-p, --print Print the output to console and create no files
[string] [default: false]
--configName Specify a custom name for the configuration file
[string] [default: ".ts-for-girrc.js"]
-d, --noNamespace Do not export all symbols for each module as a n
amespace [string] [default: false]
-n, --noComments Do not generate documentation comments
[string] [default: false]
--promisify Generate promisified functions for async/finish
calls [string] [default: true]
--npmScope Scope of the generated NPM packages
[string] [default: "@girs"]
--workspace Uses the workspace protocol for the generated pa
ckages which can be used with package managers l
ike Yarn and PNPM [string] [default: false]
--onlyVersionPrefix Only use the version prefix for the ambient modu
le exports. This is useful if, for whatever reas
on, you want to use different library versions o
f the same library in your project.
[string] [default: false]
--noPrettyPrint Do not prettify the generated types
[string] [default: false]
--noAdvancedVariants Disable GLib.Variant class with string parsing
[string] [default: true]
--package Generate the typescript types with package.json
support [string] [default: false]
Examples:
ts-for-gir generate Run 'ts-for-gir generate' in your gj
s project to generate typings for yo
ur project, pass the gir modules you
need for your project
ts-for-gir generate Gtk* You can also use wild cards
ts-for-gir generate '*' If you want to parse all of your loc
ally installed gir modules run
ts-for-gir generate --configName='.ts-fo Use a special config file
r-gir.gtk4.rc.js
ts-for-gir generate --ignore=Gtk-4.0 xra Generate .d.ts. files but not for Gt
ndr-1.3 k-4.0 and xrandr-1.3
Error: Could not generify Gtk 4.0
at file:///home/yash/.npm/_npx/9947fdcb15df8564/node_modules/@ts-for-gir/lib/lib/generics/generify.js:17:19
at generify (file:///home/yash/.npm/_npx/9947fdcb15df8564/node_modules/@ts-for-gir/lib/lib/generics/generify.js:25:5)
at DependencyManager.transform (file:///home/yash/.npm/_npx/9947fdcb15df8564/node_modules/@ts-for-gir/lib/lib/gir/registry.js:105:9)
at GenerationHandler.start (file:///home/yash/.npm/_npx/9947fdcb15df8564/node_modules/@ts-for-gir/cli/lib/generation-handler.js:35:18)
at async Object.handler (file:///home/yash/.npm/_npx/9947fdcb15df8564/node_modules/@ts-for-gir/cli/lib/commands/generate.js:34:5)
Im not really sure whats going here
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
Aylur commentedon Nov 14, 2024
This usually means you don't have the gtk4 gir file installed.
What distro are you on?
yashranjan1 commentedon Nov 14, 2024
arch
rogtino commentedon Nov 15, 2024
I'm currently using nixos.Same error happened here:
iCultureBud commentedon Nov 16, 2024
I have the exact same error after installing
aylurs-gtk-shell-giton Arch and runningags init.Edit:
ags runseems to work.yashranjan1 commentedon Nov 16, 2024
Ags run works because type generation is not essential for the widgets to work. Types are useful for LSP, makes writing your config a lot easier to debug.
OBLIXi-ON commentedon Nov 17, 2024
The recommend command isn't working for me either. It's showing
zsh: no matches found: /usr/share/*/gir-1.0.ags rundoesn't work either.Edit: surrounding it like
"/usr/share/*/gir-1.0"shows the same error mentioned at the top.Loneattic commentedon Nov 19, 2024
Use only one "-g" path where the girs modules are located (most likely it's
/usr/share/gir-1.0/).*without quotes also generates errors. Try"*"or just remove it, it's still the default option.npx -y @ts-for-gir/cli generate --ignoreVersionConflicts --outdir <YOUR-@girs-PATH> -g /usr/share/gir-1.0/yashranjan1 commentedon Nov 20, 2024
Tried this and got another error
Either way i think this is something ags needs to address. If this was a one off thing that only i faced it would make sense to find my own fix, but the fact that so many people are facing this probably means that installing ags does not guarantee you have everything you need to develop with it installed and ready to use. Hope this can be addressed soon!
RewardedIvan commentedon Nov 22, 2024
I had the same issue as well, but after a bit of thinking I figured this might have something to do with astal and then I realized i never installed astal or anything and just assumed it came with ags, but after running
fixed it, but this should probably be in the ags documentation
The-Lost-Light commentedon Nov 23, 2024
libastal-io-git libastal-git is required in ags in AUR(libastal-meta)
I install both two but still have this problem
vnva commentedon Nov 23, 2024
I had same issue (ArchLinux)
List command prints me
But most of these dependencies are installed in the system.
kotontrion commentedon Nov 23, 2024
@vnva thanks, that was really helpful. Those files are provided by the
gobject-introspectionpackage. I thought gjs depends on it so it should be installed, but its only a make dependency. So this should be added as a dependency to AGS, I will do so later.vnva commentedon Nov 23, 2024
@kotontrion thanks, yes, that was the problem, after installing this package I was able to initialize the project using
ags init.iCultureBud commentedon Nov 23, 2024
@vnva Thank you - after installing those packages
ags typesrun through without problems. :)JohnOberhauser commentedon Nov 26, 2024
This didn't work for me when I had my config in a custom directory. I had to move it to
./config/agsArtemChandragupta commentedon Nov 26, 2024
For me on NixOS this solution does not work when my ags config is in my nixos configuration.
agentx3 commentedon Jan 15, 2025
I am also on NixOS. I diagnosed the issue by using the
listsubcommand of@ts-for-gir/cli@4.0.0-beta.19while passing in the gir directories ( same-gflags as the recommendedgeneratecommand).I resolved my issue by adding
grapheneandgtk4into theextraPackagesof ags, so it possibly might be worth adding those into buildInputs as wellpurrion commentedon Apr 28, 2025
Today, I encountered the same issue on
Fedora42, and resolved it by installinggtk4-devel.So, if I'm not using
gtk4, can I just ignore it?Otherwise, would you consider updating the docs?
Perodactyl commentedon May 7, 2025
I just found the solution to my issue. Some files in my NPM cache were owned by root, and it was trying to overwrite them.
nmattela commentedon Jul 16, 2025
Had the same issue on Arch
As per @vnva 's suggestion, I did
npx @ts-for-gir/cli list, I got:So I looked into
/usr/share/gir-1.0/and saw thatRest-1.0was already installed, but not the0.7version.Doing
pacman -Qs resttold me thatRest-1.0came from the packagelibrest.On my other Arch machine where
ags typesdoes work, and hadRest-0.7installed,pacman -Qs resttold me thatRest-0.7came from the packagerest 0.8.1+r4+ge5ee6ef-1, but I have no idea what that package is or where it came from.Eventually I copied the files
/usr/share/gir-1.0/Rest-0.7.girand /usr/share/gir-1.0/RestExtras-0.7.girfrom my Arch machine whereags types` does work, to my Arch machine where it does not. Solved the problem but it's not a very satisfactory solution.kotontrion commentedon Jul 16, 2025
By default AGS will generate types for all installed gir libs, which in many cases is not necessary. You can specify a pattern for which libs to generate the types. Eg running
ags types "Astal*"is probably sufficient in most cases. The types for other libs can still be generated by running it again with a different pattern later.Maybe the default should change to a two step system. In the first step generate types for things that are actually needed for ags, eg Gtk, Gdk, Gtk layer shell, the astal libs. The second step generates the rest. Only the first step should fail, the second only print warnings. This would prevent this issue somewhat, as it won't be affected as much by random libs. Eg librest is not used by ags, astal, or any of its dependencies.
JonnieCache commentedon Aug 4, 2025
I am seeing this issue using the flake.nix, adding gtk4 and graphene don't help. It also fails using
nix run .#ags -- types "Astal*"The output is
Output of the list command:
EDIT: I was trying to do those commands directly in the
examples/gtk4/simple_bardirectory. I triednix run .#ags -- init -d ./bar/and it works fine.For context I am upgrading from 1.x to 3.x so I'm trying to develop my new config in a devshell in a clone of the ags repo, so I can keep my existing 1.x bar running until I'm ready to change my system over to the new one.
unai-ndz commentedon Sep 21, 2025
Got this recently:
Opened this
.npm/_npx/24f50c9ed13719e6/node_modules/@ts-for-gir/lib/package.jsonwhich showed:{ "name": "@ts-for-gir/lib", "version": "4.0.0-beta.38", ....Then I run (same command ags runs but using the version shown in the package.json above) and it worked (Some errors shown but it updated the classes and the ones I looked at that were wrong before are accurate now):
/usr/bin/npx -y @ts-for-gir/cli@4.0.0-beta.38 generate --ignoreVersionConflicts --outdir /home/xyze/.config/ags/@girs -g /usr/local/share/gir-1.0 -g /usr/share/gir-1.0 -g '/usr/share/*/gir-1.0' -gPixwarron commentedon Oct 19, 2025
Can confirm that running this with the right version worked for me on arch.