Can't enable PubSub feature for ephemeral temporary node

I’m trying to adopt this example to my needs and current state of libraries:

I’m able to start temporary node and some basic activity but I can’t use pubsub feature.
It is enabled in config with cfg.Pubsub.Enabled=1:

	// Create a config with default options and a 2048 bit key
	cfg, err := config.Init(ioutil.Discard, 2048)
	if err != nil {
		return "", err
	// Create the repo with the config
	err = fsrepo.Init(repoPath, cfg)
	if err != nil {
		return "", fmt.Errorf("failed to init ephemeral node: %s", err)

But it is impossible to use. Code like

func topic_sub(ctx context.Context, chnl chan string, ipfs icore.CoreAPI, topic string) {
	subscription, err := ipfs.PubSub().Subscribe(ctx, topic)

returns “Error! Failed topic subscribtion in topic_subexperimental pubsub feature not enabled. Run daemon with --enable-pubsub-experiment to use.” And it points out that pubsub is not enabled actually.
Any ideas how to make it work?

1 Like

Facing the same issue, were you able to figure it out?

Sorry to say but nope, the project had died soon after my post :frowning_face:

Hey, I have figured it out and it is working for me now.

Adding the extra options like this made it work in addition to setting the config like you set in the question

	// Construct the node
	nodeOptions := &core.BuildCfg{
		Online:    true,
		Routing:   libp2p.DHTOption, // Full DHT node - fetch and store DHT Records
		Repo:      repo,
		Permanent: true,
		ExtraOpts: map[string]bool{
			"pubsub": true,
1 Like

Great, thank you for your research!