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

Type generation fails #617

Open
yashranjan1 opened this issue Nov 14, 2024 · 17 comments
Open

Type generation fails #617

yashranjan1 opened this issue Nov 14, 2024 · 17 comments

Comments

@yashranjan1
Copy link

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/[email protected] 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/[email protected] 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

@Aylur
Copy link
Owner

Aylur commented Nov 14, 2024

This usually means you don't have the gtk4 gir file installed.
What distro are you on?

@yashranjan1
Copy link
Author

arch

@rogtino
Copy link

rogtino commented Nov 15, 2024

I'm currently using nixos.Same error happened here:

󰯉 ags types
error: type generation failed, try running
/nix/store/jz54v1m0ldqivx5i45q8i05pz5clf842-nodejs-20.18.0/bin/npx -y @ts-for-gir/[email protected] generate * --ignoreVersionConflicts --outdir /home/gus/.config/ags/@girs -g /usr/local/share/gir-1.0 -g /usr/share/gir-1.0 -g /usr/share/*/gir-1.0 -g /nix/store/slm7mb2626vbl9qwq9cgp1ix6szcyqvw-gtk+3-3.24.43-dev/share/gir-1.0 -g /nix/store/59knjxjaqd279yp8z8miw2kis2szql9n-at-spi2-core-2.54.0-dev/share/gir-1.0 -g /nix/store/1hhi03gg5jdb2fa5gb9ncklziczax741-glib-2.82.1-dev/share/gir-1.0 -g /nix/store/wmbg435clgdlqn4rrn8h5f4jhmhbk24f-gdk-pixbuf-2.42.12-dev/share/gir-1.0 -g /nix/store/h42324qxqnmmmpjg3skvvmllr1l75cma-gsettings-desktop-schemas-47.1/share/gir-1.0 -g /nix/store/774vgpw939f69xb47f2wz31j6di094bp-pango-1.54.0-dev/share/gir-1.0 -g /nix/store/sv5fvv7pimim1z48yyy4fs0amr93qg4q-harfbuzz-9.0.0-dev/share/gir-1.0 -g /nix/store/qrwgj7jhyazhs1kgr61y9k48v4dljxjb-librsvg-2.58.3-dev/share/gir-1.0 -g /nix/store/9qrx21qdxh9vlnmg4hzsh3saiig54q3q-gobject-introspection-wrapped-1.82.0-dev/share/gir-1.0 -g /nix/store/qrwgj7jhyazhs1kgr61y9k48v4dljxjb-librsvg-2.58.3-dev/share/gir-1.0 -g /nix/store/1hhi03gg5jdb2fa5gb9ncklziczax741-glib-2.82.1-dev/share/gir-1.0 -g /nix/store/wmbg435clgdlqn4rrn8h5f4jhmhbk24f-gdk-pixbuf-2.42.12-dev/share/gir-1.0 -g /nix/store/slm7mb2626vbl9qwq9cgp1ix6szcyqvw-gtk+3-3.24.43-dev/share/gir-1.0 -g /nix/store/59knjxjaqd279yp8z8miw2kis2szql9n-at-spi2-core-2.54.0-dev/share/gir-1.0 -g /nix/store/h42324qxqnmmmpjg3skvvmllr1l75cma-gsettings-desktop-schemas-47.1/share/gir-1.0 -g /nix/store/774vgpw939f69xb47f2wz31j6di094bp-pango-1.54.0-dev/share/gir-1.0 -g /nix/store/sv5fvv7pimim1z48yyy4fs0amr93qg4q-harfbuzz-9.0.0-dev/share/gir-1.0 -g /nix/store/4x4lqw85ljkg0x3qx0fxiq49fcjb4l5l-gobject-introspection-1.82.0-dev/share/gir-1.0 -g /nix/store/yw3rnyycd5avw59pczzlainzw954x6sr-astal-0.1.0-dev/share/gir-1.0 -g /nix/store/3smm6wfkc7vkc87lykpgpqq431sdq5sh-astal-3.0.0-dev/share/gir-1.0 -g /nix/store/7mjw24p0xfm45vcm04dxlmfydg00c3jw-gtk-layer-shell-0.9.0-dev/share/gir-1.0 -g /nix/store/3m08jxm3d356kksnb149p13wgdqnq23r-astal-4.0.0-dev/share/gir-1.0 -g /nix/store/k887w7d4qwd9n1lmnk4yblwd11mv5vak-gtk4-4.16.3-dev/share/gir-1.0 -g /nix/store/cnsg6r87wm9rc3v2c757kd0c96adb358-graphene-1.10.8-dev/share/gir-1.0 -g /nix/store/z5yzpa7h7iq4712akdvb14cjl3rs5sqi-gtk4-layer-shell-1.0.4-dev/share/gir-1.0

@pomeluce
Copy link

This usually means you don't have the gtk4 gir file installed. What distro are you on?

I also encountered this problem. I am also using archlinux and have installed gtk4 dependencies. Is there any solution?

@iCultureBud
Copy link

iCultureBud commented Nov 16, 2024

I have the exact same error after installing aylurs-gtk-shell-git on Arch and running ags init.

Edit: ags run seems to work.

@yashranjan1
Copy link
Author

Edit: ags run seems to work.

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
Copy link

OBLIXi-ON commented 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 run doesn't work either.

Edit: surrounding it like "/usr/share/*/gir-1.0" shows the same error mentioned at the top.

@Loneattic
Copy link

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
Copy link
Author

npx -y @ts-for-gir/cli generate --ignoreVersionConflicts --outdir YOUR-@girs-PATH -g /usr/share/gir-1.0/

Tried this and got another error

Error: Failed to import Vulkan in GstVulkan, not installed or accessible.
    at GirModule.assertInstalledImport (file:///home/yash/.npm/_npx/4001ac8ae3bf4948/node_modules/@ts-for-gir/lib/lib/gir-module.js:279:19)
    at IntrospectedRecord.isSimpleType (file:///home/yash/.npm/_npx/4001ac8ae3bf4948/node_modules/@ts-for-gir/lib/lib/gir/class.js:821:45)
    at file:///home/yash/.npm/_npx/4001ac8ae3bf4948/node_modules/@ts-for-gir/lib/lib/gir/class.js:851:54
    at Array.every (<anonymous>)
    at IntrospectedRecord.isSimple (file:///home/yash/.npm/_npx/4001ac8ae3bf4948/node_modules/@ts-for-gir/lib/lib/gir/class.js:851:38)
    at file:///home/yash/.npm/_npx/4001ac8ae3bf4948/node_modules/@ts-for-gir/lib/lib/validators/class.js:111:84
    at Array.filter (<anonymous>)
    at removeComplexFields (file:///home/yash/.npm/_npx/4001ac8ae3bf4948/node_modules/@ts-for-gir/lib/lib/validators/class.js:98:31)
    at chainVisitors (file:///home/yash/.npm/_npx/4001ac8ae3bf4948/node_modules/@ts-for-gir/lib/lib/validators/class.js:208:23)
    at ClassVisitor.visitClass (file:///home/yash/.npm/_npx/4001ac8ae3bf4948/node_modules/@ts-for-gir/lib/lib/validators/class.js:213:28)

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
Copy link

RewardedIvan commented 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

yay -S libastal-io-git libastal-git
ags types

fixed it, but this should probably be in the ags documentation

@The-Lost-Light
Copy link
Contributor

libastal-io-git libastal-git is required in ags in AUR(libastal-meta)
I install both two but still have this problem

@vnva
Copy link

vnva commented Nov 23, 2024

I had same issue (ArchLinux)

List command prints me

> npx @ts-for-gir/cli list 

Dependencies not found:
- cairo-1.0
- freetype2-2.0
- xlib-2.0
- xft-2.0
- fontconfig-2.0
- libxml2-2.0
- Vulkan-1.0
- DBus-1.0

But most of these dependencies are installed in the system.

> pacman -Q cairo freetype2 fontconfig libxml2 vulkan-radeon dbus

cairo 1.18.2-2
freetype2 2.13.3-1
fontconfig 2:2.15.0-2
libxml2 2.13.5-1
vulkan-radeon 1:24.2.7-1
dbus 1.14.10-2

@kotontrion
Copy link
Contributor

@vnva thanks, that was really helpful. Those files are provided by the gobject-introspection package. 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
Copy link

vnva commented 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
Copy link

@vnva Thank you - after installing those packages ags types run through without problems. :)

@JohnOberhauser
Copy link

This didn't work for me when I had my config in a custom directory. I had to move it to ./config/ags

@ArtemChandragupta
Copy link

For me on NixOS this solution does not work when my ags config is in my nixos configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests