A DOZEN hefty wooden crates sit outside a small factory on the outskirts of Lucknow, the capital of India’s most populous state, Uttar Pradesh. On the shop floor inside, where chattering machines bag and package herbal teas, a manager explains what will happen when he opens the crates. “His job will go,” he says, nodding at one boiler-suited operator. “And his over there, and that one’s too.”

Improved technology has already boosted the firm’s output fivefold since its launch in 2002, with no increase in staff. The new machines in the crates, which require a single operator rather than three, will double it again. But the manager insists that, as in the past, he will somehow find jobs for everyone—as drivers or even watchmen if necessary.

Few Indian workers have such conscientious employers. They do, however, increasingly face similar risks of redundancy, or of failing to find a decent job in the first place. A big part of the challenge stems from automation. According to McKinsey, a consulting firm, machines could eliminate some 52% of India’s jobs if current technology were adopted across the board. This affects not only manufacturing. For the first time in nearly a decade, India’s high-flying IT industry this year laid off thousands of workers. A survey of private-sector workers by the Economic Times, an Indian daily, found 62% agreeing that their job prospects were shrinking.

India’s labour force will soon overtake China as the world’s largest, but the country is struggling to generate opportunities for a workforce with the wrong skills. Slowing economic growth, a decline in investment rates, the shock of economic reforms, a long-term decline in agricultural employment and a faulty education system have combined to reduce the proportion of Indians who hold proper jobs.

India is also in the midst of a demographic transition, as birth rates fall. The share of the population that is of working age is peaking relative to the share of children and old people. That should, as long as jobs are available, lift the rate of economic growth. Yet the proportion of working-age people actually in work has been falling steadily (see chart). India, home to a sixth of humanity, is in danger of forfeiting its “demographic dividend”.

The numbers are daunting. Just to keep unemployment in check, India needs to create some 10m-12m jobs a year. When economic growth is strong, it has just been able to do that: the government’s Labour Bureau estimates that from 2013 to 2015 the economy added 11m jobs a year. A slowdown in the prior two-year period, however, had kept job growth at half that level, leaving a shortfall of 10m jobs. The tipping point seems to be economic growth of about 7%. Ominously, growth has steadily slowed since 2016; in the quarter ending in June it fell to 5.7%, although transitory factors may have played a part in that. The data on jobs are also unreliable. Officially, India’s jobless rate has hovered at an enviable 4% for many years. But the government is generous in its definition of work. By its own admission, some 35% of workers in 2015—the most recent year for which in-depth surveys are available—had held a job for less than 11 months in the previous year. According to the World Bank, over 30% of Indians between the ages of 15 and 29 are NEETs, “not in education, employment or training”. This may be an exaggeration. In a country where some 86% of workers are reckoned to be in “informal” employment—ie untaxed and without a contract—counting can be difficult. But the pressure for jobs is real. Last year thousands of Jats, a community in northern India that traditionally owned small farms but has become increasingly urbanised, rioted to press demands for an expanded quota of government jobs. The unrest left 25 dead and briefly severed the main water supply to Delhi, India’s capital. Other castes and ethnic groups have taken similar action in recent years, in the same hope of strong-arming their way into jobs. Successive Indian governments have tried to tackle the dearth of employment. One massive state program, the world’s largest, doles out millions of temporary make-work jobs in rural areas. The current government has also tried to boost skills. Last year its National Skill Development Corporation trained some 557,000 workers. By its own count, however, only 12% of these trainees found jobs. The central government has also promised to clarify India’s dauntingly complex labour rules: it says it will streamline compliance, and shrink some 44 different labour statutes into four simpler bundles.

The rules are indeed onerous. In many states, firms with more than 100 employees must seek government approval to fire a single worker. As a result, many resort to contractors to fill their payrolls with temporary hires, a solution that evades red tape but produces neither dedicated staff nor a happy workplace. Other companies simply choose to stay small: some 98.6% of non-farm businesses have fewer than 10 workers. This carries a long-term cost in productivity. Indian garment-makers, for example, tend to be tiny. Small wonder that competitors in such countries as Vietnam and Bangladesh, where giant factories are plugged into global supply chains, now far outpace India in exports.

India’s biggest industrial firms have found yet another solution. Surprisingly for a relatively poor country, their factories tend be more capital-intensive than those of their counterparts in China. For example, at a sprawling site outside the southern city of Chennai run by Hyundai, a South Korean firm, some 8,500 workers toil alongside 530 robots. The fully digitised facility turned out 661,000 cars last year, one every 72 seconds. It ranks second in productivity and quality among the firm’s 34 factories around the world; its engine plant is number one. “What we have here is an integrated cascade between suppliers and the assembly line,” says Ganesh Mani, the vice-president for production, “The entire ecosystem has to be in sync.”

Not all Indian workplaces can hope for such efficiency. But if the government does not do more to boost growth and to tip the balance between hiring people and installing robots, the jobs crunch will grow ever more severe. The problem requires not tinkering at the edges, but a concerted effort to put India’s economic ecosystem—from underfunded and poorly run schools, to a hopelessly clogged legal system, to ensnaring webs of red tape, to overburdened infrastructure—in sync.